diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/src/main.rs b/src/main.rs index bd89baa..5ea93f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,6 +32,7 @@ mod macros; mod modules; mod route; +mod timing; mod xml; #[macro_use] @@ -65,28 +66,6 @@ static DATABASE: Lazy<Mutex<PickleDb>> = Lazy::new(|| { }) }); -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(); -} - -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<dyn std::error::Error>> { std::env::set_var("RUST_LOG", "windmark,locus=trace"); @@ -102,11 +81,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { windmark::Response::not_found(ERROR_HANDLER_RESPONSE) }); router.set_fix_path(true); - - time_section(&mut time_mount, "creating router"); - - time_mounts("module", &mut time_mount, || stateless!(router, modules)); - + timing::time_section(&mut time_mount, "creating router"); + timing::time_mounts("module", &mut time_mount, || { + stateless!(router, modules); + }); std::thread::spawn(modules::search::index); router.run().await |