Skip to content

Commit c87bd3c

Browse files
committed
Show time values relative to the root in pq marker info
1 parent f0ff7e7 commit c87bd3c

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/profile-query-cli/formatters.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -255,22 +255,15 @@ Marker ${result.markerHandle}: ${result.name}`;
255255
output += `Type: ${result.markerType ?? 'None'}\n`;
256256
output += `Category: ${result.category.name}\n`;
257257

258-
// Time and duration
259-
const startStr = result.start.toFixed(3);
258+
// Time and duration (relative to profile root start)
259+
const rootStart = result.context.rootRange.start;
260+
const startStr = formatDuration(result.start - rootStart);
260261
if (result.end !== null) {
261-
const endStr = result.end.toFixed(3);
262-
const durationMs = result.duration!;
263-
let durationStr: string;
264-
if (durationMs < 1) {
265-
durationStr = `${(durationMs * 1000).toFixed(1)}µs`;
266-
} else if (durationMs < 1000) {
267-
durationStr = `${durationMs.toFixed(2)}ms`;
268-
} else {
269-
durationStr = `${(durationMs / 1000).toFixed(3)}s`;
270-
}
271-
output += `Time: ${startStr}ms - ${endStr}ms (${durationStr})\n`;
262+
const endStr = formatDuration(result.end - rootStart);
263+
const durationStr = formatDuration(result.duration!);
264+
output += `Time: ${startStr} - ${endStr} (${durationStr})\n`;
272265
} else {
273-
output += `Time: ${startStr}ms (instant)\n`;
266+
output += `Time: ${startStr} (instant)\n`;
274267
}
275268

276269
output += `Thread: ${result.threadHandle} (${result.friendlyThreadName})\n`;
@@ -293,7 +286,7 @@ Marker ${result.markerHandle}: ${result.name}`;
293286
if (result.stack && result.stack.frames.length > 0) {
294287
output += '\nStack trace:\n';
295288
if (result.stack.capturedAt !== undefined) {
296-
output += ` Captured at: ${result.stack.capturedAt.toFixed(3)}ms\n`;
289+
output += ` Captured at: ${formatDuration(result.stack.capturedAt - rootStart)}\n`;
297290
}
298291

299292
for (let i = 0; i < result.stack.frames.length; i++) {

0 commit comments

Comments
 (0)