Skip to content

gh-161008: Fix missing statistics in heatmap replay output - #161010

Open
deadlovelll wants to merge 4 commits into
python:mainfrom
deadlovelll:gh-161008-heatmap
Open

deadlovelll wants to merge 4 commits into
python:mainfrom
deadlovelll:gh-161008-heatmap

Conversation

@deadlovelll

Copy link
Copy Markdown
Contributor

Fix missing statistics in heatmap replay output

For details see gh-161008

content = pathlib.Path(tmp, "index.html").read_text(
encoding="utf-8"
)
if with_stats:

@maurycy maurycy Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The with_stats=False branch doesn't assert anything.

Maybe we could assert what we expect for a file without the stats extension? I think that here it'd be 0.0 sec, 0.0, N/A, N/A. If that's the case, do we want to show 0.0 sec for old files, instead of N/A?

}
self.stats.update(kwargs)

def set_replay_stats(self, info):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a verbatim copy of

def set_replay_stats(self, info):
"""Restore measured statistics stored in a binary profile."""
duration_sec = info.get("duration_sec")
sample_rate = info.get("sample_rate")
if duration_sec is None or sample_rate is None:
return
self.set_stats(
self.sample_interval_usec,
duration_sec,
sample_rate,
error_rate=info.get("error_rate"),
missed_samples=info.get("missed_samples"),
mode=self.stats.get("mode"),

I wonder how we can avoid this?

There's an interesting disprepancy:

if hasattr(collector, "set_replay_stats"):
collector.set_replay_stats(info)
if hasattr(collector, "set_mode"):
collector.set_mode(info.get("mode"))

if hasattr(collector, 'set_stats'):
collector.set_stats(self.sample_interval_usec, running_time_sec, sample_rate, error_rate, missed_samples, mode=self.mode)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! I’ve taken all your comments into account, and it’s true that I didn’t quite finish writing the test...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants