-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheventtrace.py
More file actions
33 lines (29 loc) · 870 Bytes
/
eventtrace.py
File metadata and controls
33 lines (29 loc) · 870 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
#
# Part of FPSpy
#
# Copyright (c) 2019 Alex Bernat - see LICENSE
#
import sys
import fileinput
import csv
if(len(sys.argv)!=2):
sys.exit("Error - needs time interval in ms")
interval = int(sys.argv[1])
events = 0
first_line = sys.stdin.readline()
first_line=first_line.split()
initialmillis= int(first_line[0])
prevmillis = int(first_line[0])
with open('trace.csv', 'w+') as csvfile:
csvwriter = csv.writer(csvfile, delimiter=' ', quotechar='|', quoting=csv.QUOTE_MINIMAL)
csvwriter.writerow(['Time,','Events'])
for line in sys.stdin:
results = line.split()
millis = int(results[0])
events = events + 1
if(millis-prevmillis<interval):
events = events +1
else:
csvwriter.writerow([str(prevmillis)+",",str(events)])
prevmillis=millis
events=0