-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcollectdata.py
33 lines (26 loc) · 1.01 KB
/
collectdata.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
import re, os, glob
def CollectData(N, mem):
for fn in glob.glob("search_tmp.*"):
os.remove(fn)
with open("search.cpp", "rt") as f:
src = f.read()
ints = mem / 8
src = re.sub(r"const int SIZE = (\d*);", r"const int SIZE = %d;" % N, src)
src = re.sub(r"const int ARR_SAMPLES = (\(.*?\))", r"const int ARR_SAMPLES = %d" % ints, src)
src = re.sub(r"const int KEY_SAMPLES = (\(.*?\))", r"const int KEY_SAMPLES = %d" % ints, src)
with open("search_tmp.cpp", "wt") as f:
f.write(src)
with open("c.bat", "rt") as f:
bat = f.read()
bat = bat.replace("search.cpp", "search_tmp.cpp")
os.system(bat)
logname = "res_%04d_%d.log" % (N, mem)
os.system("search_tmp >res/" + logname)
os.system("search_tmp >res/" + logname)
for fn in glob.glob("res/*"):
os.remove(fn)
sizes = [16, 32, 64, 128, 256, 512, 1024]
#sizes = [128, 256, 512, 1024, 2048, 4096]
for s in sizes:
CollectData(s, 64<<10)
# CollectData(s, 512<<10)