-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.py
35 lines (32 loc) · 924 Bytes
/
parse.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
import re
filename = 'time_tests.txt'
pattern = ''
lines = None
temp = []
with open(filename, 'r') as file:
lines = file.readlines()
file.close()
for line in lines:
line = line.strip()
if line.startswith('size'):
if '1024' in line:
line = line.replace('1024', '1KB')
elif '1048576' in line:
line = line.replace('1048576', '1MB')
elif '1073741824' in line:
line = line.replace('1073741824', '1GB')
print(line)
continue
elif line.startswith('real'):
min = 0
_, time = line.split('\t')
if '1m' in time:
min = 60
time = time.replace('m', '')
time = time.replace('s', '')
temp.append(float(float(time)+min))
if len(temp) == 10:
temp = sorted(temp)
avg = float(temp[4]+temp[5])/float(2)
print(str(avg))
temp = []