-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
48 lines (37 loc) · 1.11 KB
/
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
import sys, os
import SITA as sita
if __name__ == '__main__':
import time
import itertools
import multiprocessing
from multiprocessing import Process
def applyAll(filenames):
for f in filenames:
if f == None:
break
print f.strip()
sita.SitaElements(f.strip(), filterSize=10, fcomb='SI')
argvs = sys.argv
if len(argvs) < 2:
print "usage: python ./run.py [file]"
sys.exit(-1)
f = open(argvs[1])
lines = f.readlines()
f.close()
print "number of cpu:", multiprocessing.cpu_count()
if multiprocessing.cpu_count() >= len(lines):
N_seg = len(lines)
else:
N_seg = multiprocessing.cpu_count() - 1
s = time.time()
threads = []
for files in itertools.izip_longest( *[iter(lines)] * (len(lines)/N_seg) ):
threads.append( Process(target=applyAll, args=(files, )) )
print "number of threads:", len(threads)
for t in threads:
t.start()
for t in threads:
t.join()
e = time.time()
print "extract SITA; done."
print "Processing time", (e-s)