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 json
import os
import library.python.import_tracing.lib.converters.base as base_converter
class ChromiumTraceConverter(base_converter.BaseTraceConverter):
@staticmethod
def _yield_in_chrome_trace_format(events, pid):
for event in events:
yield {
"cat": event.modname,
"name": event.filename,
"ph": "B",
"ts": event.start_time,
"pid": pid,
"tid": event.tid,
"args": {},
}
yield {
"cat": event.modname,
"name": event.filename,
"ph": "E",
"ts": event.end_time,
"pid": pid,
"tid": event.tid,
}
def dump(self, events, filepath):
pid = os.getpid()
with open(filepath, "w") as file:
file.write(json.dumps(tuple(self._yield_in_chrome_trace_format(events, pid))))
|