-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
55 lines (40 loc) · 1.34 KB
/
util.py
File metadata and controls
55 lines (40 loc) · 1.34 KB
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
from glob import glob
import re
import json
import numpy as np
from constants import TS_PATH, CLAS_PATH
def get_light_benchmark_list(cut=10):
benchmarks = []
cnt = 0
for path in glob(CLAS_PATH + '/*.json'):
benchmark = re.sub(r'\.json$', '', path.split('/')[-1])
benchmarks.append(benchmark)
cnt += 1
if cnt >= cut:
break
return np.unique(benchmarks).tolist()
def get_benchmark_list():
benchmarks = []
for path in glob(CLAS_PATH + '/*.json'):
benchmark = re.sub(r'\.json$', '', path.split('/')[-1])
benchmarks.append(benchmark)
return np.unique(benchmarks).tolist()
def load_timeseries(benchmark):
return load(TS_PATH, benchmark)
def load_classification(benchmark):
return load(CLAS_PATH, benchmark)
def load(dirpath, benchmark):
path = '{}/{}.json'.format(dirpath, benchmark)
with open(path) as f:
return json.load(f)
def foreach_fork(ts, classification, steady_state_only=False):
for f, ts_ in enumerate(ts):
c = classification['forks'][f]
st = classification['steady_state_starts'][f]
if steady_state_only is False:
yield f, ts_, st
elif c == 'steady state':
yield f, ts_, st
def get_benchmark_name(path):
filename = path.split('/')[-1]
return re.sub('\.csv$', '', filename)