aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-04-25 01:21:14 -0700
committerFuwn <[email protected]>2022-04-25 01:21:14 -0700
commita2bf8d8397613dc5933e3e5c4c8bb172edeeec1a (patch)
treedc8adcea9bb07b3301881d9986f9e2bf9bbff9fc /src
parentrefactor(modules): move complex router setup to modules (diff)
downloadlocus-a2bf8d8397613dc5933e3e5c4c8bb172edeeec1a.tar.xz
locus-a2bf8d8397613dc5933e3e5c4c8bb172edeeec1a.zip
refactor(router): move section timer to function
Diffstat (limited to 'src')
-rw-r--r--src/main.rs15
1 files changed, 10 insertions, 5 deletions
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<dyn std::error::Error>> {
std::env::set_var("RUST_LOG", "windmark,locus=trace");
@@ -108,11 +117,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}));
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);