Skip to content

Commit cbbda1c

Browse files
committed
fix: timeline profile format fix to be compatible with firefox profiler
Still a lot of work to be done there
1 parent 094372d commit cbbda1c

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lib/services/timeline-profiler-service.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ export class TimelineProfilerService implements ITimelineProfilerService {
6969
data.split("\n").forEach((line) => {
7070
const trace = this.toTrace(line.trim());
7171
if (trace) {
72-
deviceTimeline.startPoint ??= trace.from;
73-
deviceTimeline.timeline.push(trace);
72+
deviceTimeline.startPoint ??= trace[0].ts;
73+
deviceTimeline.timeline.push(...trace);
7474
}
7575
});
7676
}
@@ -80,28 +80,36 @@ export class TimelineProfilerService implements ITimelineProfilerService {
8080
return this.$projectConfigService.getValue("profiling") === "timeline";
8181
}
8282

83-
private toTrace(text: string): ChromeTraceEvent | undefined {
83+
private toTrace(text: string): ChromeTraceEvent[] | undefined {
8484
const result = text.match(TIMELINE_LOG_RE);
8585
if (!result) {
8686
return;
8787
}
8888

8989
const trace = {
90-
domain: result[2]?.trim().replace(":", ""),
90+
domain: result[2]?.trim().replace(":", ".").toLowerCase(),
9191
name: result[3].trim(),
9292
from: parseFloat(result[4]),
9393
to: parseFloat(result[5]),
9494
};
9595

96-
return {
96+
return [{
97+
args:{},
9798
pid: 1,
9899
tid: 1,
99100
ts: trace.from * 1000,
100-
dur: (trace.to - trace.from) * 1000,
101101
name: trace.name,
102102
cat: trace.domain ?? "default",
103-
ph: ChromeTraceEventPhase.COMPLETE,
104-
};
103+
ph: ChromeTraceEventPhase.BEGIN,
104+
}, {
105+
args:{},
106+
pid: 1,
107+
tid: 1,
108+
ts: trace.to * 1000,
109+
name: trace.name,
110+
cat: trace.domain ?? "default",
111+
ph: ChromeTraceEventPhase.END,
112+
}];
105113
}
106114

107115
private writeTimelines() {

0 commit comments

Comments
 (0)