-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph_results.py
49 lines (39 loc) · 1.19 KB
/
graph_results.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
import os
import sys
from boomslang import Plot, Line
import json
data_dir = sys.argv[1]
colors = ('r', 'g', 'b', 'c', 'y', 'm', 'k')
runs = []
for root, dirs, files in os.walk(data_dir):
records = [a_file for a_file in files if ".json" in a_file]
for record in records:
record_handle = open(os.path.join(root, record), 'r')
client_data = json.load(record_handle)
record_handle.close()
client_run = []
for test in client_data:
if u'success' in test:
client_run.append(test[u'end_time'] - test[u'start_time'])
else:
client_run.append(0)
runs.append(client_run)
average_run = []
for i in range(0, len(runs[0])):
average_run.append(sum([a_run[i] for a_run in runs])/len(runs))
print average_run
plot = Plot()
for run in runs:
line = Line()
line.yValues = run
line.xValues = list(range(0, len(run)))
plot.add(line)
# Also add in the average line
avg_line = Line()
avg_line.yValues = average_run
avg_line.xValues = list(range(0, len(run)))
avg_line.color = 'r'
plot.add(avg_line)
plot.xLabel = "Test Index"
plot.yLabel = "Miliseconds"
plot.save(os.path.join(data_dir, "graph.png"))