-
Notifications
You must be signed in to change notification settings - Fork 0
/
umpf_test.py
55 lines (38 loc) · 1.1 KB
/
umpf_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import multiprocessing as mp
import pp
import timeit
import umpf
import umpf_test
def f(x,y):
for j in xrange(1000):
i = x * y * x * y * j
i = x * y * x * y * j
i = x * y * x * y * j
return (x,y)
class Boris(object):
def g(self, x, y):
return f(x,y)
def __call__(self, x, y):
return f(x,y)
def run():
count = 500
for i in umpf.map(umpf_test.f, xrange(count), xrange(count+2)):
i
boris = umpf_test.Boris()
for i in umpf.map(boris.g, xrange(count), xrange(count+2)):
i
for i in umpf.map(boris, xrange(count), xrange(count+2)):
i
if __name__ == "__main__":
repeats = 10
duplicates = 3
t = timeit.Timer(run)
print "map times", t.repeat(duplicates, repeats)
umpf.Hub.pool = mp.Pool()
t = timeit.Timer(run)
print "multiprocessing times", t.repeat(duplicates, repeats)
del umpf.Hub.pool
umpf.Hub.server = pp.Server()
t = timeit.Timer(run)
print "PP times", t.repeat(duplicates, repeats)
del umpf.Hub.server