aboutsummaryrefslogtreecommitdiff
path: root/src/timing.rs
blob: 6e81ffe4da27954701b03d9c3ab732a47d042d89 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use tokio::time::Instant;

pub fn time_mounts<T>(context: &str, timer: &mut Instant, mut mounter: T)
where
  T: FnMut(),
{
  mounter();

  info!(
    "{} mounts took {}ms",
    context,
    timer.elapsed().as_nanos() as f64 / 1_000_000.0
  );

  *timer = Instant::now();
}

pub fn time_section(timer: &mut Instant, context: &str) {
  info!(
    "{} took {}ms",
    context,
    timer.elapsed().as_nanos() as f64 / 1_000_000.0
  );

  *timer = Instant::now();
}