-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathextractTimes.py
33 lines (31 loc) · 962 Bytes
/
extractTimes.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
import sys
import os
import json
"""
fname: the name of the file containing the test
results
tname: the name of the file used for the test
We assume tname does not include the extension
"""
def extractTimes(fname,tname):
if "dl" in fname:
resname = "dl" + tname + "test.csv"
else:
resname = "vdms" + tname + "test.csv"
resfile = open(resname, "w+")
fh = open(fname, "r")
for line in fh.readlines():
if "dlstorage" in line:
resfile.write(line)
resfile.write("time,first_frame\n")
else:
json_data = json.loads(line)
totTime = json_data['time']
if 'first_frame' in json_data:
first_frame = json_data['first_frame']
resfile.write(str(totTime) + "," + str(first_frame) + "\n")
else:
resfile.write(str(totTime) + ", \n")
fh.close()
resfile.close()
extractTimes("vdout8.txt","f65sec")