Crates.io | voxell_timer |
lib.rs | voxell_timer |
version | |
source | src |
created_at | 2024-10-18 03:25:52.112632 |
updated_at | 2024-11-28 10:18:58.949616 |
description | Perf timers for Rust |
homepage | |
repository | https://github.com/Paladynee/timer-rs |
max_upload_size | |
id | 1413859 |
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` |
size | 0 |
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.
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);
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));
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));