diff options
| author | Fuwn <[email protected]> | 2023-04-07 17:48:35 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-04-07 17:48:35 -0700 |
| commit | bc23774bd41d2195be526790095a0b7adce3ec24 (patch) | |
| tree | 313894a26f13152a31216582ad93817a9e18b8c4 | |
| parent | deps(windmark): bump 0.3.3 -> 0.3.4 (diff) | |
| download | locus-bc23774bd41d2195be526790095a0b7adce3ec24.tar.xz locus-bc23774bd41d2195be526790095a0b7adce3ec24.zip | |
refactor(timing): move timing interface to timing module
| -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 |