From a2bf8d8397613dc5933e3e5c4c8bb172edeeec1a Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 25 Apr 2022 01:21:14 -0700 Subject: refactor(router): move section timer to function --- src/main.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index ef66cf5..82fd838 100644 --- a/src/main.rs +++ b/src/main.rs @@ -93,6 +93,15 @@ where T: FnMut() { *timer = Instant::now(); } +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(); +} + #[windmark::main] async fn main() -> Result<(), Box> { std::env::set_var("RUST_LOG", "windmark,locus=trace"); @@ -108,11 +117,7 @@ async fn main() -> Result<(), Box> { })); router.set_fix_path(true); - info!( - "creating router took {}ms", - time_mount.elapsed().as_nanos() as f64 / 1_000_000.0 - ); - time_mount = Instant::now(); + time_section(&mut time_mount, "creating router"); time_mounts("module", &mut time_mount, || { router.attach_stateless(modules::uptime::module); -- cgit v1.2.3