2020-03-24 22:57:37 +03:00
|
|
|
# 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`:
|
|
|
|
|
2020-03-24 23:30:25 +03:00
|
|
|
in your crate:
|
|
|
|
```
|
|
|
|
[dependencies]
|
|
|
|
scopetime = "0.1"
|
|
|
|
```
|
|
|
|
|
|
|
|
in your code:
|
2020-03-24 22:57:37 +03:00
|
|
|
```rust
|
|
|
|
fn foo(){
|
|
|
|
scope_time!("foo");
|
2020-03-24 23:30:25 +03:00
|
|
|
|
|
|
|
// ... do something u wanna measure
|
2020-03-24 22:57:37 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
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
|
|
|
|
```
|