This repository was archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 502
/
Copy pathres_parser.py
47 lines (39 loc) · 1.52 KB
/
res_parser.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
import csv
from ...utils import get_value_by_pattern
def parse_res_file(path):
"""
Read data from an OLTPBench-generated file that ends with ".res".
Parameters
----------
path : str
Path to a ".res" file.
Returns
-------
incremental_metrics : [dict]
The throughput of the test at different times.
"""
gvbp = get_value_by_pattern
def get_latency_val(row, pattern):
value = gvbp(row, pattern, None)
return float("{:.4}".format(value)) if value else value
incremental_metrics = []
with open(path) as csvfile:
reader = csv.DictReader(csvfile, delimiter=',')
for row in reader:
incremental_metrics.append({
"time": float(gvbp(row, 'time(sec)', None)),
"throughput": float(gvbp(row, 'throughput(req/sec)', None)),
"latency": {key: get_latency_val(row, pat)
for key, pat in [
('l_25', '25th_lat(ms)'),
('l_75', '75th_lat(ms)'),
('l_90', '90th_lat(ms)'),
('l_95', '95th_lat(ms)'),
('l_99', '99th_lat(ms)'),
('avg', 'avg_lat(ms)'),
('median', 'median_lat(ms)'),
('min', 'min_lat(ms)'),
('max', 'max_lat(ms)')
]}
})
return incremental_metrics