MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / read_avg_speed

Function read_avg_speed

PythonAPI/examples/plot_avg_speed.py:7–41  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

5WINDOW = 5
6
7def read_avg_speed(path):
8 data = []
9 with open(path) as f:
10 last_time = 0
11 line = f.readline()
12 window_total_speed = [0, 0, 0]
13 window_num = 0
14
15 global_total_speed = 0
16 global_num = 0
17
18 while line:
19 s = line.split(' ')
20 s = [float(x) for x in s]
21 t = s[0]
22
23 if int(t) >= last_time + INTERVAL - WINDOW and int(t) < last_time + INTERVAL + WINDOW:
24 window_total_speed[0] += s[7]
25 window_total_speed[1] += s[8]
26 window_total_speed[2] += s[9]
27 window_num += 1
28 elif int(t) >= last_time + INTERVAL + WINDOW:
29 data.append((
30 last_time + INTERVAL,
31 window_total_speed[0] / window_num,
32 window_total_speed[1] / window_num,
33 window_total_speed[2] / window_num))
34 window_total_speed = [0, 0, 0]
35 window_num = 0
36 last_time = last_time + INTERVAL
37 line = f.readline()
38
39 print(path)
40
41 return data
42
43data_gamma = read_avg_speed('statistics.gamma.log')
44data_simple = read_avg_speed('statistics.ttc.log')

Callers 1

plot_avg_speed.pyFile · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected