Skip to content

Commit 43b0e01

Browse files
authored
gh-153293: Clear opcode statistics in the live profiler's reset_stats() (#153295)
1 parent 65afd65 commit 43b0e01

3 files changed

Lines changed: 5 additions & 0 deletions

File tree

Lib/profiling/sampling/live_collector/collector.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ def build_stats_list(self):
702702
def reset_stats(self):
703703
"""Reset all collected statistics."""
704704
self.result.clear()
705+
self.opcode_stats.clear()
705706
self.per_thread_data.clear()
706707
self.thread_ids.clear()
707708
self.view_mode = "ALL"

Lib/test/test_profiling/test_sampling_profiler/test_live_collector_interaction.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def test_reset_stats(self):
9999
"cumulative_calls": 75,
100100
"total_rec_calls": 0,
101101
}
102+
self.collector.opcode_stats[("test.py", 1, "func")][100] = 5
102103

103104
# Reset
104105
self.collector.reset_stats()
@@ -107,6 +108,7 @@ def test_reset_stats(self):
107108
self.assertEqual(self.collector.successful_samples, 0)
108109
self.assertEqual(self.collector.failed_samples, 0)
109110
self.assertEqual(len(self.collector.result), 0)
111+
self.assertEqual(len(self.collector.opcode_stats), 0)
110112

111113
def test_increase_refresh_rate(self):
112114
"""Test increasing refresh rate (faster updates)."""
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix the live sampling profiler TUI keeping stale aggregated opcode
2+
statistics after a stats reset.

0 commit comments

Comments
 (0)