Skip to content

Commit 80c202a

Browse files
committed
imporove metrics capture logic
1 parent 4c6d141 commit 80c202a

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎Lib/profiling/sampling/_heatmap_assets/heatmap_index_template.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<div class="stat-card">
6767
<div class="stat-icon">&#9201;</div>
6868
<div class="stat-data">
69-
<span class="stat-value"><!-- DURATION --> sec</span>
69+
<span class="stat-value"><!-- DURATION --></span>
7070
<span class="stat-label">Duration</span>
7171
</div>
7272
<div class="stat-sparkline"></div>

‎Lib/profiling/sampling/heatmap_collector.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,15 +752,17 @@ def _generate_index_html(self, index_path: Path, file_stats: List[FileStats]):
752752
missed_samples_class = "good"
753753

754754
# Populate template
755+
duration_sec = self.stats.get('duration_sec')
756+
sample_rate = self.stats.get('sample_rate')
755757
replacements = {
756758
"<!-- INLINE_CSS -->": f"<style>\n{self._template_loader.index_css}\n</style>",
757759
"<!-- INLINE_JS -->": f"<script>\n{self._template_loader.index_js}\n</script>",
758760
"<!-- PYTHON_LOGO -->": self._template_loader.logo_html,
759761
"<!-- PYTHON_VERSION -->": f"{sys.version_info.major}.{sys.version_info.minor}",
760762
"<!-- NUM_FILES -->": f"{len(file_stats):n}",
761763
"<!-- TOTAL_SAMPLES -->": f"{self._total_samples:n}",
762-
"<!-- DURATION -->": fmt(self.stats.get('duration_sec', 0)),
763-
"<!-- SAMPLE_RATE -->": fmt(self.stats.get('sample_rate', 0)),
764+
"<!-- DURATION -->": f"{fmt(duration_sec)} sec" if duration_sec is not None else "N/A",
765+
"<!-- SAMPLE_RATE -->": fmt(sample_rate) if sample_rate is not None else "N/A",
764766
"<!-- ERROR_RATE -->": error_rate_str,
765767
"<!-- ERROR_RATE_WIDTH -->": str(error_rate_width),
766768
"<!-- ERROR_RATE_CLASS -->": error_rate_class,

0 commit comments

Comments
 (0)