Add print_time helper
This commit is contained in:
parent
f44aee27d3
commit
6577a7622d
@ -106,6 +106,21 @@ pub fn profile(desc: &str) -> Profiler {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn print_time(desc: &str) -> impl Drop + '_ {
|
||||
struct Guard<'a> {
|
||||
desc: &'a str,
|
||||
start: Instant,
|
||||
}
|
||||
|
||||
impl Drop for Guard<'_> {
|
||||
fn drop(&mut self) {
|
||||
eprintln!("{}: {:?}", self.desc, self.start.elapsed())
|
||||
}
|
||||
}
|
||||
|
||||
Guard { desc, start: Instant::now() }
|
||||
}
|
||||
|
||||
pub struct Profiler {
|
||||
desc: Option<String>,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user