-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdescribe_infer_times.py
58 lines (49 loc) · 1.43 KB
/
describe_infer_times.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
import argparse
import os
import numpy as np
import pandas as pd
def make_parser():
parser = argparse.ArgumentParser(
description=('Generate statistical description on a series of log '
'analysis.'))
parser.add_argument('outfile', help='text file to write')
parser.add_argument('indir', help='directory where log analysis lie')
parser.add_argument('names', nargs='+', help='the names of the inputs')
return parser
def calc_stats(indir, names):
filenames = [os.path.join(indir, x + '.txt') for x in names]
means = []
stds = []
q0s = []
q25s = []
q50s = []
q75s = []
q100s = []
for filename in filenames:
arr = np.loadtxt(filename)
means.append(np.mean(arr))
stds.append(np.std(arr))
q0s.append(np.percentile(arr, 0))
q25s.append(np.percentile(arr, 25))
q50s.append(np.percentile(arr, 50))
q75s.append(np.percentile(arr, 75))
q100s.append(np.percentile(arr, 100))
df = pd.DataFrame(
{
'mean': means,
'std': stds,
'min': q0s,
'q25': q25s,
'median': q50s,
'q75': q75s,
'max': q100s,
},
index=names
)
return df
def main():
args = make_parser().parse_args()
df = calc_stats(args.indir, args.names)
df.to_csv(args.outfile, index_label='solver')
if __name__ == '__main__':
main()