Skip to content

Commit

Permalink
Use built-in Instant::elapsed method
Browse files Browse the repository at this point in the history
  • Loading branch information
lpenz committed May 9, 2022
1 parent 5ba437e commit 10f8947
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/progbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl Progbar {
let dur = self.duration.as_millis();
let refresh = self.refresh_delay.as_millis();
let total = self.barsize(overhead, dur, refresh);
let elapsed = self.elapsed();
let elapsed = self.start.elapsed();
let ratio = elapsed.as_millis() as f32 / self.duration.as_millis() as f32;
let left = if ratio < 1_f32 {
((total as f32) * ratio).ceil() as usize
Expand All @@ -88,10 +88,6 @@ impl Progbar {
(left, right, total)
}

fn elapsed(&self) -> time::Duration {
time::Instant::now() - self.start
}

fn spinner(&mut self) -> char {
self.ispinner = (self.ispinner + 1) % 4;
SPINNERS[self.ispinner]
Expand Down
2 changes: 1 addition & 1 deletion src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub async fn run_once(cli: &Cli, last_rundata: RunData, pb: &mut Progbar) -> Res
Ok(RunData {
status: Some(status),
output: vecboth,
duration: time::Instant::now() - start,
duration: start.elapsed(),
})
}

Expand Down

0 comments on commit 10f8947

Please sign in to comment.