profiling
This commit is contained in:
@@ -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))
|
||||
Reference in New Issue
Block a user