voxell_timer

Crates.iovoxell_timer
lib.rsvoxell_timer
version
sourcesrc
created_at2024-10-18 03:25:52.112632
updated_at2024-11-28 10:18:58.949616
descriptionPerf timers for Rust
homepage
repositoryhttps://github.com/Paladynee/timer-rs
max_upload_size
id1413859
Cargo.toml error:TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Voxell Paladynee (Paladynee)

documentation

README

Voxell's Timers

let data = time_eprintln!{hello mom, generate_data() };
// -> hello mom: 309ms

This library provides a simple way to time code execution. Simply use the provided macros/functions to time your code to get a Duration and the result of the block/closure.

Example 1

use voxell_timer::*;

let (result, time) = time! {
    for _ in 0..1_000_000 {
        let _ = std::hint::black_box(3);
    }
    10
};
eprintln!("Took {}ms", time.as_millis());
assert_eq!(result, 10);

Example 2

use voxell_timer::*;

let haystack = vec![1, 2, 3, 4, 5, 6];
let result = time_println! {
    "Finding needle in haystack",
    let needle = 4;
    haystack.iter().find(|a| **a == needle)
};

assert_eq!(result, Some(&4));

Example 3

use voxell_timer::*;

let haystack = vec![1, 2, 3, 4, 5, 6];
let result = time_fn_println("Finding needle in haystack", || {
    let needle = 4;
    haystack.iter().find(|a| **a == needle)
});
assert_eq!(result, Some(&4));
Commit count: 10

cargo fmt