Blog changeover notice
3 weeks ago
Searching the Answer to Life, the Universe and Everything.
# Use multiprocessing backend.
backend = MPBackend()
# Start the thread that listens for I/O from the processes.
backend.iohandler.start()
# Do some calculations.
a = backend.spawn(reduce, operator.mul, xrange(1, 50000))
b = backend.spawn(reduce, operator.mul, xrange(1, 50000))
# When you need the results, sync them.
a, b = sync(a, b)
# When done, shut down the I/O thread so the application can exit.
backend.iohandler.stop()
| Threads | Time (in Seconds) | Difference |
|---|---|---|
| 1 | 21.15 | - |
| 2 | 23.17 | +9.56% |
| 3 | 24.83 | +7.16% |
| 4 | 25.13 | +1.21% |
| 5 | 23.67 | -5.81% |
| 6 | 24.90 | +5.21% |
| 7 | 24.74 | -0.64% |
| 8 | 25.36 | +2.52% |
| Processes | Time (in Seconds) | Difference |
|---|---|---|
| 1 | 20.36 | - |
| 2 | 10.43 | -48.78% |
| 3 | 6.91 | -33.79% |
| 4 | 5.32 | -22.96% |
| 5 | 5.90 | +11.01% |
| 6 | 5.13 | -13.09% |
| 7 | 4.86 | -5.33% |
| 8 | 4.59 | -5.50% |