MCPcopy Index your code
hub / github.com/python/cpython / createFlamegraph

Function createFlamegraph

Lib/profiling/sampling/_flamegraph_assets/flamegraph.js:574–602  ·  view source on GitHub ↗
(tooltip, rootValue, data)

Source from the content-addressed store, hash-verified

572}
573
574function createFlamegraph(tooltip, rootValue, data) {
575 const chartArea = document.querySelector('.chart-area');
576 const width = chartArea ? chartArea.clientWidth - 32 : window.innerWidth - 320;
577 const heatColors = getHeatColors();
578
579 const isDifferential = data && data.stats && data.stats.is_differential;
580 const diffColors = isDifferential ? getDiffColors() : null;
581
582 let chart = flamegraph()
583 .width(width)
584 .cellHeight(20)
585 .transitionDuration(300)
586 .minFrameSize(1)
587 .tooltip(tooltip)
588 .inverted(true)
589 .setColorMapper(function (d) {
590 if (d.depth === 0) return 'transparent';
591
592 if (isDifferential) {
593 return getDiffColorForNode(d, diffColors);
594 }
595
596 const percentage = d.data.value / rootValue;
597 const level = getHeatLevel(percentage);
598 return heatColors[level];
599 });
600
601 return chart;
602}
603
604function renderFlamegraph(chart, data) {
605 d3.select("#chart").datum(data).call(chart);

Callers 2

updateFlamegraphViewFunction · 0.85
initFlamegraphFunction · 0.85

Calls 5

getHeatColorsFunction · 0.85
getDiffColorsFunction · 0.85
getDiffColorForNodeFunction · 0.85
getHeatLevelFunction · 0.85
widthMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…