-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRun.py
50 lines (36 loc) · 1018 Bytes
/
Run.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
from Bracket_Class import Bracket, clean_year
import multiprocessing as mp
import time
def parallel_bracket(year):
B = Bracket(year)
B.run()
B.write_to_csv()
B.write()
def p_print(n, label):
if n == 0:
return ''
elif n == 1:
return '{} {} '.format(n, label)
else:
return '{} {}s '.format(n, label)
def htime(s):
H, i = divmod(s, 3600)
M, S = divmod(i, 60)
S = int(S)
return p_print(H, 'hour') + p_print(M, 'minute') + p_print(S, 'second')
if __name__ == '__main__':
print time.ctime()
t1 = time.time()
processes = []
for year in map(clean_year, range(3,15)):
processes.append( mp.Process(target=parallel_bracket, args=(year,)) )
for p in processes:
p.start()
for p in processes:
p.join()
B = {}
for year in map(clean_year, range(3,15)):
B[year] = Bracket.from_file(year)
print time.ctime()
t2 = time.time()
print 'Finished in {}!'.format( htime( t2 -t1 ) )