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

Function initFlamegraph

Lib/profiling/sampling/_flamegraph_assets/flamegraph.js:1406–1449  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1404// ============================================================================
1405
1406function initFlamegraph() {
1407 ensureLibraryLoaded();
1408 restoreUIState();
1409 setupLogos();
1410
1411 if (EMBEDDED_DATA.strings) {
1412 stringTable = EMBEDDED_DATA.strings;
1413 normalData = resolveStringIndices(EMBEDDED_DATA, EMBEDDED_DATA.strings);
1414 } else {
1415 normalData = EMBEDDED_DATA;
1416 }
1417
1418 // Initialize opcode mapping from embedded data
1419 initOpcodeMapping(EMBEDDED_DATA);
1420
1421 // Inverted data will be built on first toggle
1422 invertedData = null;
1423
1424 initThreadFilter(normalData);
1425
1426 // Toggle legend based on differential mode
1427 const isDifferential = normalData && normalData.stats && normalData.stats.is_differential;
1428 const heatmapLegend = document.getElementById('heatmap-legend-section');
1429 const diffLegend = document.getElementById('diff-legend-section');
1430 if (isDifferential) {
1431 if (heatmapLegend) heatmapLegend.style.display = 'none';
1432 if (diffLegend) diffLegend.style.display = 'block';
1433 } else {
1434 if (heatmapLegend) heatmapLegend.style.display = 'block';
1435 if (diffLegend) diffLegend.style.display = 'none';
1436 }
1437
1438 const tooltip = createPythonTooltip(normalData);
1439 const chart = createFlamegraph(tooltip, normalData.value, normalData);
1440 renderFlamegraph(chart, normalData);
1441 initSearchHandlers();
1442 initSidebarResize();
1443 handleResize();
1444
1445 const toggleInvertBtn = document.getElementById('toggle-invert');
1446 if (toggleInvertBtn) {
1447 toggleInvertBtn.addEventListener('click', toggleInvert);
1448 }
1449}
1450
1451// Keyboard shortcut: Enter/Space activates toggle switches
1452document.addEventListener('keydown', function(e) {

Callers 1

flamegraph.jsFile · 0.85

Calls 13

ensureLibraryLoadedFunction · 0.85
setupLogosFunction · 0.85
resolveStringIndicesFunction · 0.85
initOpcodeMappingFunction · 0.85
initThreadFilterFunction · 0.85
createPythonTooltipFunction · 0.85
createFlamegraphFunction · 0.85
renderFlamegraphFunction · 0.85
initSearchHandlersFunction · 0.85
initSidebarResizeFunction · 0.85
handleResizeFunction · 0.85
getElementByIdMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…