Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Lib/profiling/sampling/_flamegraph_assets/flamegraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let invertedData = null;
let currentThreadFilter = 'all';
let isInverted = false;
let useModuleNames = true;
let zoomedNodeValue = null;

// Heat colors are now defined in CSS variables (--heat-1 through --heat-8)
// and automatically switch with theme changes - no JS color arrays needed!
Expand Down Expand Up @@ -316,6 +317,7 @@ function createPythonTooltip(data) {
const selfSamples = d.data.self || 0;
const selfMs = (selfSamples / 1000).toFixed(2);
const percentage = ((d.data.value / data.value) * 100).toFixed(2);
const relativePercentage = Math.min(100, ((d.data.value / (zoomedNodeValue ?? data.value)) * 100)).toFixed(2);
const calls = d.data.calls || 0;
const childCount = d.children ? d.children.length : 0;
const source = d.data.source;
Expand Down Expand Up @@ -439,6 +441,11 @@ function createPythonTooltip(data) {
<span class="tooltip-stat-label">Percentage:</span>
<span class="tooltip-stat-value accent">${percentage}%</span>

${relativePercentage != percentage && relativePercentage != "100.00" ? `
<span class="tooltip-stat-label">Relative Percentage:</span>
<span class="tooltip-stat-value accent">${relativePercentage}%</span>
` : ''}

${calls > 0 ? `
<span class="tooltip-stat-label">Function Calls:</span>
<span class="tooltip-stat-value">${calls.toLocaleString()}</span>
Expand Down Expand Up @@ -620,6 +627,9 @@ function createFlamegraph(tooltip, rootValue, data) {
const percentage = d.data.value / rootValue;
const level = getHeatLevel(percentage);
return heatColors[level];
})
.onClick(function (d) {
zoomedNodeValue = d.data.value;
});

return chart;
Expand All @@ -629,6 +639,7 @@ function renderFlamegraph(chart, data) {
d3.select("#chart").datum(data).call(chart);
window.flamegraphChart = chart;
window.flamegraphData = data;
zoomedNodeValue = null;
populateStats(data);
}

Expand Down Expand Up @@ -1269,6 +1280,7 @@ function filterDataByThread(data, threadId) {

function resetZoom() {
if (window.flamegraphChart) {
zoomedNodeValue = null;
window.flamegraphChart.resetZoom();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update the tooltip on the Tachyon flame graph to show both absolute and relative percentages.
Loading