Open JO-WTF opened 5 months ago
On my machine, both versions take around 6.5 seconds, but the Python version is indeed a bit faster on average.
Unfortunately, Go doesn't offer Coroutines, so instead I use one Goroutine per process. The Goroutines are synchronized via channels, so effectively only one runs at any given time. You might find https://research.swtch.com/coro interesting. In the case of the bank example, one process per customer is created, so the Go version needs 1 million Goroutines. Creating them and constantly switching between them of course impacts performance quite a bit.
Compared to Go, Python offers Generators, which are used to make SimPy work without creating a thread or something similar per process. Even if Python is much slower than Go in principle, this leads to the similar performance for this example.
If you want better performance right now, you might want to try the C++ version of this library: https://github.com/fschuetz04/simcpp20. On my machine, the same bank example with 1 million customers takes about 0.5 seconds :)
Thanks for your reply.
I tried simcpp20 actually. However, not every simpy functionality is implemented in simcpp20 yet (store, container for example), so it seems there are a lot work to do before it can be applied to a project to replace simpy.
I created the bank renege example model respectively with simpy and simgo.
What suprised me is that the run time of both models are quite similar, Python even faster for 10%.
I never used Go before, so wondering what the cause may be. Do you have any idea?
simpy code:
Python 3.12.1 output:
simgo code:
Golang go version go1.22.2 linux/amd64 output: