viz: integer ticks on the x axis, fix small cycle numbers (#14792)

This commit is contained in:
qazal
2026-02-16 17:07:40 +08:00
committed by GitHub
parent 47d39a6b8b
commit d213fe95a0

View File

@@ -172,7 +172,7 @@ function formatCycles(cycles) {
const M = Math.floor(cycles / 1e6), K = Math.floor((cycles % 1e6) / 1e3), s = Math.round(cycles % 1e3);
const parts = [];
if (M) parts.push(`${M}M`);
if (K || (!M && s)) parts.push(`${K}K`);
if (K) parts.push(`${K}K`);
if (s || (!M && !K)) parts.push(`${s}`);
return parts.join(" ");
}
@@ -527,6 +527,7 @@ async function renderProfiler(path, unit, opts) {
drawLine(ctx, xscale.range(), [0, 0]);
let lastLabelEnd = -Infinity;
for (const tick of xscale.ticks()) {
if (!Number.isInteger(tick)) continue;
const x = xscale(tick);
drawLine(ctx, [x, x], [0, tickSize]);
const labelX = x+ctx.lineWidth+2;