-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlatency.py
More file actions
35 lines (28 loc) · 833 Bytes
/
latency.py
File metadata and controls
35 lines (28 loc) · 833 Bytes
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
#!/usr/bin/python3
import re
import sys
import statistics
if __name__ == '__main__':
file = sys.argv[1]
with open(file) as f:
lines = f.readlines()
init = []
latency = []
for line in lines:
line = line.strip()[43:]
m = re.match(r' * (\d+): Store:init', line)
if m != None:
init.append(int(m[1]))
latency.append([])
continue
m = re.match(r'Time OneGoogleProvider: (\d+)', line)
if m != None:
latency[-1].append(int(m[1]))
first = []
last = []
for l in latency:
first.append(l[0])
last.append(l[-1])
print('Average init: %s' % statistics.mean(init))
print('Average latency (First): %s' % statistics.mean(first))
print('Average latency (Last): %s' % statistics.mean(last))