profiling

This commit is contained in:
fumfar hiwi
2019-11-27 14:02:23 +01:00
parent 8639b5a155
commit 28ab850bee
21 changed files with 123 additions and 487 deletions
+32
View File
@@ -0,0 +1,32 @@
import json
import csv
import sys
if len(sys.argv) == 1:
print("No file was provided")
else:
trace_events = []
call_stack = []
with open(sys.argv[1], "r") as in_file:
csv_reader = csv.reader(in_file, delimiter=',')
for line in csv_reader:
if line[0] == "->":
call_stack.append(line)
elif line[0] == "<-":
call = call_stack.pop()
trace_events.append({
"pid": 1,
"tid": 1,
"ts" : int(call[1]),
"dur": int(line[1])-int(call[1]),
"ph" : "X",
"name": call[2],
"args": {
"file": f"({call[3]}:{call[4]})"
}
})
else:
print("invalid syntax")
break
with open("out.json", "w") as out_file:
out_file.write(json.dumps({"traceEvents": trace_events}, indent=4))