-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextractStartupTelemetry.py
39 lines (32 loc) · 1.1 KB
/
extractStartupTelemetry.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
36
37
38
39
#!/bin/env python
import os
import sys
import json
import stat
if len(sys.argv) != 2:
print "Usage: extractStartupTelemetry.py <Telemetry pings directory> > outFile.csv"
sys.exit(2)
# Read all Telemetry payload files in directory
telemetryPings = []
for filename in os.listdir(sys.argv[1]):
path = sys.argv[1] + os.sep + filename
mtime = os.stat(path)[stat.ST_MTIME]
file = open(path, "r")
rawData = file.read()
data = json.loads(rawData)
telemetryPings.append((mtime, data["payload"]["simpleMeasurements"]))
# Present the data chronologically
sortedPings = sorted(telemetryPings)
milestones = ["start", "main", "startupCrashDetectionBegin",
"AMI_startup_begin", "AMI_startup_end", "createTopLevelWindow",
"firstPaint", "sessionRestoreInitialized",
"delayedStartupFinished", "sessionRestored", "firstLoadURI"]
print ",".join(milestones)
for (mtime, ping) in sortedPings:
row = ""
for mstone in milestones:
if mstone not in ping:
row += "-1,"
continue
row += str(ping[mstone]) + ","
print row