multiprocessing vs thread performance

Jarkko Torppa torppa at staff.megabaud.fi
Mon Dec 29 17:30:42 CET 2008


On 2008-12-29, mk <mrkafk at gmail.com> wrote:
> janislaw wrote:
>
>> Ah, so there are 100 processes at time. 200secs still don't sound
>> strange.
>
> I ran the PEP 371 code on my system (Linux) on Python 2.6.1:
>
> Linux SLES (9.156.44.174) [15:18] root ~/tmp/src # ./run_benchmarks.py 
> empty_func.py
>
> Importing empty_func
> Starting tests ...
> non_threaded (1 iters)  0.000005 seconds
> threaded (1 threads)    0.000235 seconds
> processes (1 procs)     0.002607 seconds
>
> non_threaded (2 iters)  0.000006 seconds
> threaded (2 threads)    0.000461 seconds
> processes (2 procs)     0.004514 seconds
>
> non_threaded (4 iters)  0.000008 seconds
> threaded (4 threads)    0.000897 seconds
> processes (4 procs)     0.008557 seconds
>
> non_threaded (8 iters)  0.000010 seconds
> threaded (8 threads)    0.001821 seconds
> processes (8 procs)     0.016950 seconds
>
> This is very different from PEP 371. It appears that the PEP 371 code 
> was written on Mac OS X.

On the PEP371 it says "All benchmarks were run using the following:
Python 2.5.2 compiled on Gentoo Linux (kernel 2.6.18.6)"

On my iMac 2.3Ghz dualcore. python 2.6

iTaulu:src torppa$ python run_benchmarks.py empty_func.py 
Importing empty_func
Starting tests ...
non_threaded (1 iters)  0.000002 seconds
threaded (1 threads)    0.000227 seconds
processes (1 procs)     0.002367 seconds

non_threaded (2 iters)  0.000003 seconds
threaded (2 threads)    0.000406 seconds
processes (2 procs)     0.003465 seconds

non_threaded (4 iters)  0.000004 seconds
threaded (4 threads)    0.000786 seconds
processes (4 procs)     0.006430 seconds

non_threaded (8 iters)  0.000006 seconds
threaded (8 threads)    0.001618 seconds
processes (8 procs)     0.012841 seconds

With python2.5 and pyProcessing-0.52

iTaulu:src torppa$ python2.5 run_benchmarks.py empty_func.py
Importing empty_func
Starting tests ...
non_threaded (1 iters)  0.000003 seconds
threaded (1 threads)    0.000143 seconds
processes (1 procs)     0.002794 seconds

non_threaded (2 iters)  0.000004 seconds
threaded (2 threads)    0.000277 seconds
processes (2 procs)     0.004046 seconds

non_threaded (4 iters)  0.000005 seconds
threaded (4 threads)    0.000598 seconds
processes (4 procs)     0.007816 seconds

non_threaded (8 iters)  0.000008 seconds
threaded (8 threads)    0.001173 seconds
processes (8 procs)     0.015504 seconds

-- 
Jarkko Torppa, Elisa



More information about the Python-list mailing list