-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate_georgesconfig.py
69 lines (51 loc) · 1.67 KB
/
create_georgesconfig.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import json
import os
from multiprocessing import Pool
from operator import itemgetter
from dyre_util import HistUtil
from analysis.util import count, cov
from util import foreach_benchmark, load_jmhresult
no_measurements = 30
cov_threshold = 0.02
def get_benchmarks():
return list(set(map(itemgetter(0), foreach_benchmark())))
# def foreach_fork():
# for benchmark, jmhdata in foreach_jmhresult():
# for i, fork_data in enumerate(jmhdata):
# yield benchmark, i, fork_data
def create_config(fork):
histutil = HistUtil()
wi = -1
for i, hist_ in enumerate(fork):
histutil.add(hist_)
hist = histutil.tohist()
if count(hist) >= no_measurements:
if cov(hist) < cov_threshold:
return [wi, wi+no_measurements]
else:
wi = i + 1
histutil.clear()
return [-1, -1]
def process_benchmark(benchmark):
data = load_jmhresult(benchmark)
res = []
for no_fork, fork in enumerate(data):
print('Running', benchmark, 'fork', no_fork)
cfg = create_config(fork)
res.append(cfg)
return res
def init_dir(dir_):
if not os.path.exists(dir_):
os.mkdir(dir_)
def write_results(benchmark, res_dir, cfg):
filename = '{}/{}.json'.format(res_dir, benchmark)
with open(filename, mode='w') as f:
json.dump(cfg, f)
if __name__ == '__main__':
res_dir = './data/georgesconfig'
init_dir(res_dir)
benchmarks = get_benchmarks()
with Pool() as pool:
results = pool.map(process_benchmark, benchmarks)
for benchmark, cfg in zip(benchmarks, results):
write_results(benchmark, res_dir, cfg)