diff --git a/Lib/profiling/sampling/_flamegraph_assets/flamegraph.js b/Lib/profiling/sampling/_flamegraph_assets/flamegraph.js index dc7bfed602f32a..b73659a13eb021 100644 --- a/Lib/profiling/sampling/_flamegraph_assets/flamegraph.js +++ b/Lib/profiling/sampling/_flamegraph_assets/flamegraph.js @@ -90,7 +90,8 @@ function toggleTheme() { // Update theme button icon const btn = document.getElementById('theme-btn'); if (btn) { - btn.innerHTML = next === 'dark' ? '☼' : '☾'; // sun or moon + btn.querySelector('.icon-moon').style.display = next === 'dark' ? 'none' : ''; + btn.querySelector('.icon-sun').style.display = next === 'dark' ? '' : 'none'; } // Re-render flamegraph with new theme colors @@ -157,7 +158,8 @@ function restoreUIState() { document.documentElement.setAttribute('data-theme', savedTheme); const btn = document.getElementById('theme-btn'); if (btn) { - btn.innerHTML = savedTheme === 'dark' ? '☼' : '☾'; + btn.querySelector('.icon-moon').style.display = savedTheme === 'dark' ? 'none' : ''; + btn.querySelector('.icon-sun').style.display = savedTheme === 'dark' ? '' : 'none'; } } diff --git a/Lib/profiling/sampling/_flamegraph_assets/flamegraph_template.html b/Lib/profiling/sampling/_flamegraph_assets/flamegraph_template.html index 05277fb225c86f..b7e00260b46d44 100644 --- a/Lib/profiling/sampling/_flamegraph_assets/flamegraph_template.html +++ b/Lib/profiling/sampling/_flamegraph_assets/flamegraph_template.html @@ -39,18 +39,43 @@ class="toolbar-btn" onclick="resetZoom()" title="Reset zoom" - >⌂ + > + + + + + > + + + + + + + + + + > + + + + + diff --git a/Lib/profiling/sampling/_heatmap_assets/heatmap.js b/Lib/profiling/sampling/_heatmap_assets/heatmap.js index 038aa44b3df619..8ac4ef43e53b37 100644 --- a/Lib/profiling/sampling/_heatmap_assets/heatmap.js +++ b/Lib/profiling/sampling/_heatmap_assets/heatmap.js @@ -24,7 +24,8 @@ function toggleTheme() { // Update theme button icon const btn = document.getElementById('theme-btn'); if (btn) { - btn.innerHTML = next === 'dark' ? '☼' : '☾'; // sun or moon + btn.querySelector('.icon-moon').style.display = next === 'dark' ? 'none' : ''; + btn.querySelector('.icon-sun').style.display = next === 'dark' ? '' : 'none'; } applyLineColors(); @@ -39,7 +40,8 @@ function restoreUIState() { document.documentElement.setAttribute('data-theme', savedTheme); const btn = document.getElementById('theme-btn'); if (btn) { - btn.innerHTML = savedTheme === 'dark' ? '☼' : '☾'; + btn.querySelector('.icon-moon').style.display = savedTheme === 'dark' ? 'none' : ''; + btn.querySelector('.icon-sun').style.display = savedTheme === 'dark' ? '' : 'none'; } } } diff --git a/Lib/profiling/sampling/_heatmap_assets/heatmap_index.js b/Lib/profiling/sampling/_heatmap_assets/heatmap_index.js index 4ddacca5173d34..8eb6af0db5335e 100644 --- a/Lib/profiling/sampling/_heatmap_assets/heatmap_index.js +++ b/Lib/profiling/sampling/_heatmap_assets/heatmap_index.js @@ -28,7 +28,8 @@ function toggleTheme() { // Update theme button icon const btn = document.getElementById('theme-btn'); if (btn) { - btn.innerHTML = next === 'dark' ? '☼' : '☾'; // sun or moon + btn.querySelector('.icon-moon').style.display = next === 'dark' ? 'none' : ''; + btn.querySelector('.icon-sun').style.display = next === 'dark' ? '' : 'none'; } applyHeatmapBarColors(); @@ -41,7 +42,8 @@ function restoreUIState() { document.documentElement.setAttribute('data-theme', savedTheme); const btn = document.getElementById('theme-btn'); if (btn) { - btn.innerHTML = savedTheme === 'dark' ? '☼' : '☾'; + btn.querySelector('.icon-moon').style.display = savedTheme === 'dark' ? 'none' : ''; + btn.querySelector('.icon-sun').style.display = savedTheme === 'dark' ? '' : 'none'; } } } diff --git a/Lib/profiling/sampling/_heatmap_assets/heatmap_index_template.html b/Lib/profiling/sampling/_heatmap_assets/heatmap_index_template.html index 98996bdbf5ffb1..3620f8efb8058a 100644 --- a/Lib/profiling/sampling/_heatmap_assets/heatmap_index_template.html +++ b/Lib/profiling/sampling/_heatmap_assets/heatmap_index_template.html @@ -17,12 +17,29 @@ Heatmap Report
+ + + + + + > + + + + +
diff --git a/Lib/profiling/sampling/_heatmap_assets/heatmap_pyfile_template.html b/Lib/profiling/sampling/_heatmap_assets/heatmap_pyfile_template.html index 3fb6d3a6b91dbb..91b629b2628244 100644 --- a/Lib/profiling/sampling/_heatmap_assets/heatmap_pyfile_template.html +++ b/Lib/profiling/sampling/_heatmap_assets/heatmap_pyfile_template.html @@ -17,14 +17,35 @@
- + + + + + + + + + + + > + + + + +
diff --git a/Lib/profiling/sampling/heatmap_collector.py b/Lib/profiling/sampling/heatmap_collector.py index a860ed870e3e40..f1181e8159247d 100644 --- a/Lib/profiling/sampling/heatmap_collector.py +++ b/Lib/profiling/sampling/heatmap_collector.py @@ -844,6 +844,7 @@ def _generate_index_html(self, index_path: Path, file_stats: List[FileStats]): "": f"", "": f"", "": self._template_loader.logo_html, + "": f"{sys.version_info.major}.{sys.version_info.minor}", "": str(len(file_stats)), "": f"{self._total_samples:,}", "": f"{self.stats.get('duration_sec', 0):.1f}s", @@ -901,6 +902,7 @@ def _generate_file_html(self, output_path: Path, filename: str, "": f"", "": f"", "": self._template_loader.logo_html, + "": f"{sys.version_info.major}.{sys.version_info.minor}", } html_content = self._template_loader.file_template diff --git a/Lib/profiling/sampling/stack_collector.py b/Lib/profiling/sampling/stack_collector.py index b7aa7f5ff82da3..e437facd8bb94b 100644 --- a/Lib/profiling/sampling/stack_collector.py +++ b/Lib/profiling/sampling/stack_collector.py @@ -5,6 +5,7 @@ import json import linecache import os +import sys from ._css_utils import get_combined_css from .collector import Collector, extract_lineno @@ -393,6 +394,9 @@ def _create_flamegraph_html(self, data): # Let CSS control size; keep markup simple logo_html = f'Tachyon logo' html_template = html_template.replace("", logo_html) + html_template = html_template.replace( + "", f"{sys.version_info.major}.{sys.version_info.minor}" + ) d3_js = d3_path.read_text(encoding="utf-8") fg_css = fg_css_path.read_text(encoding="utf-8")