From b5f8dfe1cf1f7cbfb13e80ef22b379c0872114fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noah=20H=C3=BCsser?= Date: Thu, 17 Feb 2022 19:52:09 +0100 Subject: [PATCH] Do not use boxcar windowing when displaying the final total of the speed --- src/state.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/state.rs b/src/state.rs index 342c58d1..c21667f4 100644 --- a/src/state.rs +++ b/src/state.rs @@ -206,11 +206,15 @@ impl ProgressState { /// The number of steps per second pub(crate) fn per_sec(&self) -> f64 { - let per_sec = 1.0 / self.est.seconds_per_step(); - if per_sec.is_nan() { - 0.0 + if matches!(&self.status, Status::InProgress) { + let per_sec = 1.0 / self.est.seconds_per_step(); + if per_sec.is_nan() { + 0.0 + } else { + per_sec + } } else { - per_sec + self.len as f64 / self.started.elapsed().as_secs_f64() } }