Skip to content

Commit f19382a

Browse files
committed
Show relative time values in pq marker info too
1 parent 0e7bd12 commit f19382a

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

‎src/profile-query-cli/formatters.ts‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,16 @@ Marker ${result.markerHandle}: ${result.name}`;
256256
output += `Category: ${result.category.name}\n`;
257257

258258
// Time and duration
259-
const startStr = result.start.toFixed(3);
259+
// result.start/end are absolute profile-internal ms timestamps.
260+
// Compute relative offsets from profile start for display.
261+
const rootStart = result.context.rootRange.start;
262+
const relStart = result.start - rootStart;
263+
const relStartStr = relStart.toFixed(3);
264+
const absStartStr = result.start.toFixed(3);
260265
if (result.end !== null) {
261-
const endStr = result.end.toFixed(3);
266+
const relEnd = result.end - rootStart;
267+
const relEndStr = relEnd.toFixed(3);
268+
const absEndStr = result.end.toFixed(3);
262269
const durationMs = result.duration!;
263270
let durationStr: string;
264271
if (durationMs < 1) {
@@ -268,9 +275,11 @@ Marker ${result.markerHandle}: ${result.name}`;
268275
} else {
269276
durationStr = `${(durationMs / 1000).toFixed(3)}s`;
270277
}
271-
output += `Time: ${startStr}ms - ${endStr}ms (${durationStr})\n`;
278+
output += `Time: ${relStartStr}ms - ${relEndStr}ms (${durationStr})\n`;
279+
output += ` Absolute: ${absStartStr}ms - ${absEndStr}ms (use with: pq zoom push ${absStartStr},${absEndStr} --absolute)\n`;
272280
} else {
273-
output += `Time: ${startStr}ms (instant)\n`;
281+
output += `Time: ${relStartStr}ms (instant)\n`;
282+
output += ` Absolute: ${absStartStr}ms\n`;
274283
}
275284

276285
output += `Thread: ${result.threadHandle} (${result.friendlyThreadName})\n`;

0 commit comments

Comments
 (0)