Skip to content

Commit 103835e

Browse files
committed
Fix flamegraph
1 parent 25e770b commit 103835e

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

Lib/profiling/sampling/flamegraph.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,22 @@ function createPythonTooltip(data) {
151151
const funcname = resolveString(d.data.funcname) || resolveString(d.data.name);
152152
const filename = resolveString(d.data.filename) || "";
153153

154+
// Don't show file location for special frames like <GC> and <native>
155+
const isSpecialFrame = filename === "~";
156+
const fileLocationHTML = isSpecialFrame ? "" : `
157+
<div style="color: #5a6c7d; font-size: 13px; margin-bottom: 12px;
158+
font-family: monospace; background: #f8f9fa;
159+
padding: 4px 8px; border-radius: 4px; word-break: break-all; overflow-wrap: break-word;">
160+
${filename}${d.data.lineno ? ":" + d.data.lineno : ""}
161+
</div>`;
162+
154163
const tooltipHTML = `
155164
<div>
156165
<div style="color: #3776ab; font-weight: 600; font-size: 16px;
157166
margin-bottom: 8px; line-height: 1.3; word-break: break-word; overflow-wrap: break-word;">
158167
${funcname}
159168
</div>
160-
<div style="color: #5a6c7d; font-size: 13px; margin-bottom: 12px;
161-
font-family: monospace; background: #f8f9fa;
162-
padding: 4px 8px; border-radius: 4px; word-break: break-all; overflow-wrap: break-word;">
163-
${filename}${d.data.lineno ? ":" + d.data.lineno : ""}
164-
</div>
169+
${fileLocationHTML}
165170
<div style="display: grid; grid-template-columns: auto 1fr;
166171
gap: 8px 16px; font-size: 14px;">
167172
<span style="color: #5a6c7d; font-weight: 500;">Execution Time:</span>
@@ -474,14 +479,23 @@ function populateStats(data) {
474479
if (i < hotSpots.length && hotSpots[i]) {
475480
const hotspot = hotSpots[i];
476481
const filename = hotspot.filename || 'unknown';
477-
const basename = filename !== 'unknown' ? filename.split('/').pop() : 'unknown';
478482
const lineno = hotspot.lineno ?? '?';
479483
let funcDisplay = hotspot.funcname || 'unknown';
480484
if (funcDisplay.length > 35) {
481485
funcDisplay = funcDisplay.substring(0, 32) + '...';
482486
}
483487

484-
document.getElementById(`hotspot-file-${num}`).textContent = `${basename}:${lineno}`;
488+
// Don't show file:line for special frames like <GC> and <native>
489+
const isSpecialFrame = filename === '~' && (lineno === 0 || lineno === '?');
490+
let fileDisplay;
491+
if (isSpecialFrame) {
492+
fileDisplay = '--';
493+
} else {
494+
const basename = filename !== 'unknown' ? filename.split('/').pop() : 'unknown';
495+
fileDisplay = `${basename}:${lineno}`;
496+
}
497+
498+
document.getElementById(`hotspot-file-${num}`).textContent = fileDisplay;
485499
document.getElementById(`hotspot-func-${num}`).textContent = funcDisplay;
486500
document.getElementById(`hotspot-detail-${num}`).textContent = `${hotspot.directPercent.toFixed(1)}% samples (${hotspot.directSamples.toLocaleString()})`;
487501
} else {

0 commit comments

Comments
 (0)