event-bus
event-bus copied to clipboard
Fix benchmark for multi-threading and multi-processing
This pull request is for fixing the error in tests/performance_testing.py. In the original implementations, the timer only records the duration for the creation of these new threads/processes, but never waits until they finished.
By adding func.join() after processes/threads creation, this problem will be fixed.
BTW, the output of this benchmark is displayed below.
CPU Heavy Tests:
Single-threaded ran the code in 4.353150909068063 seconds.
Multi-threaded ran the code in 10.680957860080525 seconds.
Multi-process ran the code in 0.7818108540959656 seconds.
IO Heavy Tests:
Single-threaded ran the code in 0.02421383303590119 seconds.
Multi-threaded ran the code in 0.03763614594936371 seconds.
Multi-process ran the code in 0.05531736393459141 seconds.
Network Heavy Tests:
Single-threaded ran the code in 8.11598255392164 seconds.
Multi-threaded ran the code in 1.9113814008887857 seconds.
Multi-process ran the code in 0.3632412769366056 seconds.
OS: Ubuntu 20.04 CPU: i9-10900X RAM: 128GB