Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible numeric underflow in sampler:43 #31

Merged
merged 1 commit into from
Jan 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ impl<'a> Sampler<'a> {
/// Should be called when a workload iteration finished.
/// If there comes the time, it will send the stats to the output.
pub async fn cycle_completed(&mut self, cycle: u64, now: Instant) {
let current_interval_duration = now - self.last_snapshot_time;
let current_interval_cycle_count = cycle - self.last_snapshot_cycle;
let current_interval_duration = now.saturating_duration_since(self.last_snapshot_time);
let current_interval_cycle_count = cycle.saturating_sub(self.last_snapshot_cycle);

// Don't snapshot if we're too close to the end of the run,
// to avoid excessively small samples:
Expand Down