-
Notifications
You must be signed in to change notification settings - Fork 1
/
ProcessTest.py
48 lines (39 loc) · 1.22 KB
/
ProcessTest.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
import multiprocessing
import time
from VaccineModel import VaccineModel
import sys
global results
results = {}
def executeFunction(id, queue):
print(id, queue)
simulation = VaccineModel({'probVaccine' : id/100, 'probDeath' : 0, 'probCure' : 0})
simulation.buildFirstFrame()
while simulation.spread():
pass
queue.put(simulation.trueResults)
nbIter = 100
if __name__ == '__main__' and sys.argv[1] == "thread":
print("STARTING TIME")
start = time.time()
p = []
q = multiprocessing.Queue()
for k in range(1):
for i in range(nbIter):
p = multiprocessing.Process(target=executeFunction, args=(i,q,))
p.start()
for i in range(nbIter):
print(q.get())
print("FINISHED")
print(" Time took : ", time.time()-start)
if __name__ == '__main__' and sys.argv[1] == "normal":
print("STARTING TIME")
start = time.time()
results = []
for i in range(nbIter):
results.append(VaccineModel({'probVaccine' : i/100, 'probDeath' : 0, 'probCure' : 0}))
results[-1].buildFirstFrame()
while results[-1].spread():
pass
print(i)
print("FINISHED")
print(" Time took : ", time.time()-start)