From 07aa0d603f4653efde56e3e766e3912376b6f240 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Tue, 24 Mar 2020 20:57:37 +0100 Subject: [PATCH] prepare for publish sub crate scopetime --- scopetime/Cargo.toml | 3 +++ scopetime/README.md | 16 ++++++++++++++++ scopetime/src/lib.rs | 1 + 3 files changed, 20 insertions(+) create mode 100644 scopetime/README.md diff --git a/scopetime/Cargo.toml b/scopetime/Cargo.toml index 26442ee3..f258e3b0 100644 --- a/scopetime/Cargo.toml +++ b/scopetime/Cargo.toml @@ -3,6 +3,9 @@ name = "scopetime" version = "0.1.0" authors = ["Stephan Dilly "] edition = "2018" +description = "log runtime of arbitrary scope" +homepage = "https://gitui.org" +license = "MIT" [dependencies] log = "0.4" diff --git a/scopetime/README.md b/scopetime/README.md new file mode 100644 index 00000000..add59555 --- /dev/null +++ b/scopetime/README.md @@ -0,0 +1,16 @@ +# scopetime + +*log runtime of arbitrary scope* + +This crate is part of the [gitui](http://gitui.org) project and can be used to annotate arbitrary scopes to `trace` their execution times via `log`: + +```rust +fn foo(){ + scope_time!("foo"); +} +``` + +the resulting log looks someting like this: +``` +19:45:00 [TRACE] (7) scopetime: [scopetime/src/lib.rs:34] scopetime: 2 ms [my_crate::foo] @my_crate/src/bar.rs:5 +``` diff --git a/scopetime/src/lib.rs b/scopetime/src/lib.rs index b090b15f..206e6c7b 100644 --- a/scopetime/src/lib.rs +++ b/scopetime/src/lib.rs @@ -1,3 +1,4 @@ +#[deny(unsafe_code)] use log::trace; use std::time::Instant;