Struct performances::zuu::Performances
source · pub struct Performances { /* private fields */ }Implementations§
source§impl Performances
impl Performances
sourcepub fn new() -> Performances
pub fn new() -> Performances
Constructor
pub fn sleep_time(&mut self, t: u64) -> &mut Performances
sourcepub fn capture<T>(&mut self, name: &str, f: &dyn Fn() -> T) -> &mut Performances
pub fn capture<T>(&mut self, name: &str, f: &dyn Fn() -> T) -> &mut Performances
Capture the execution time of the callback
nameThe function namefThe pointer to the callback
sourcepub fn print(&mut self) -> Result<(), String>
pub fn print(&mut self) -> Result<(), String>
Print the result
use std::thread::sleep;
use std::time::Duration;
use performances::zuu::Performances;
fn kool() -> bool
{
return false;
}
fn look() -> bool
{
return true;
}
fn s() -> i32
{
return 0;
}
fn get_fans() -> i32
{
return 255;
}
fn f() -> i32
{
return 1;
}
fn bad()
{
sleep(Duration::from_nanos(50));
}
Performances::new().capture("bad", &bad)
.capture("kool", &kool)
.capture("look", &look)
.capture("s", &s)
.capture("get_fans", &get_fans)
.print()
.expect("panic message");