-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwee.py
68 lines (47 loc) · 1.97 KB
/
wee.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
import math
import json
from multiprocessing import Pool
import pandas as pd
from util import load_timeseries, load_classification, foreach_fork , get_benchmark_list
from constants import WEE_PATH, CFG_PATH
def load_cfg(benchmark, technique):
with open(f"{CFG_PATH}/{technique}/{benchmark}.json") as f:
cfg = json.load(f)
return cfg
def estimate_time(measurements):
time = 0
for avgt in measurements:
no_ops = math.ceil(0.1 / avgt)
time += no_ops * avgt
return time
def compute_warmup_time(ts, last_warmup_it):
warmup_time = estimate_time(ts[:last_warmup_it + 1])
return warmup_time
def process_benchmark(benchmark):
print(f'Processing { benchmark }...')
techniques = ['OSCNN', 'FCN', 'Rocket', 'SOP', 'CV', 'RCIW', 'KLD']
# load timeseries
timeseries = load_timeseries(benchmark)
# load classification
classification = load_classification(benchmark)
results = []
for technique in techniques:
# load cfg
cfg = load_cfg(benchmark, technique)
# for each steady fork
for no_fork, ts, st in foreach_fork(timeseries, classification, steady_state_only=True):
if no_fork < len(cfg):
actual_warmup_time = compute_warmup_time(ts, st)
estimated_warmup_time = compute_warmup_time(ts, cfg[no_fork][0])
results.append((technique, benchmark, no_fork, actual_warmup_time, estimated_warmup_time))
return results
if __name__ == '__main__':
# get benchmark list
benchmarks = get_benchmark_list()
with Pool(2) as pool:
columns = ['technique', 'benchmark', 'no_fork', 'actual_warmup_time', 'estimated_warmup_time']
results = pool.map(process_benchmark, get_benchmark_list())
results = sum(results, start=[])
df = pd.DataFrame(results, columns=columns)
df['wee'] = abs(df['estimated_warmup_time'] - df['actual_warmup_time'])
df.to_csv(WEE_PATH, index=False)