multiprocessing pystone benchmark

A simple pystone benchmark using the python multiprocessing package. Seems to scale quite well - guess how many cores my machine has! 🙂

5 replies on “multiprocessing pystone benchmark”

get rid of the backquotes and use if __name__ = '__main' if you'd like others to be able to run this without errors and post their results.

'''Here is a slightly improved version that actually runs

Simple multiprocessing pystone.pystones() benchmark '''
''' Anders Wallin 2008Jun15 anders.e.e.wallin (at) '''
from test import pystone
import processing
import time


def f(q):

if __name__ == '__main__':

print 'multiprocessing test.pystones() benchmarkn'
print 'You have '+str(processing.cpuCount()) + ' CPU(s)n'
print 'ProcessestPystonestWall timetpystones/stSpeedup'

for N in range(1,processing.cpuCount()+3):

for m in range(1,N+1):
p.append( processing.Process(target=f,args=(q,)) )

for pr in p:
for r in p:
results.append( q.get() )

cputime = stop-start
if N==1: singlecpurate = N*STONES_PER_PROCESS / cputime

print "%utt%utt%.1ftt%.ftt%.1fX" % (N, N*STONES_PER_PROCESS,
cputime, N*STONES_PER_PROCESS / cputime,
N*STONES_PER_PROCESS / (cputime * singlecpurate) )

Thanks for the update, I spent some time changing it myself too. But my indentation got screwed up.
You wanted 8 cores, here it is 🙂

Xeon DP 2.66ghzx2 (E5430) = 8 cores total

multiprocessing test.pystones() benchmark

You have 8 CPU(s)

Processes Pystones Wall time pystones/s Speedup
1 500000 6.9 72727 1.0X
2 1000000 6.8 147449 2.0X
3 1500000 6.8 221729 3.0X
4 2000000 6.8 292912 4.0X
5 2500000 6.8 365283 5.0X
6 3000000 6.8 438340 6.0X
7 3500000 6.9 506806 7.0X
8 4000000 6.9 577868 7.9X
9 4500000 10.2 441739 6.1X
10 5000000 11.3 441384 6.1X

There is something going on with the quotes... I get a 'non ASCII-character' error with your program, but it runs OK if I change all the single-quotes to double-quotes.
Perhaps you're on a unicode-only system?

Thanks for the results, I've added them to the graph.

As a further exercise I'm thinking of comparing pystones or another benchmark using different speedup techniques, i.e. psyco, cython etc,
shedskin looks very interesting: