Devtimer
The compact yet complete benchmarking suite for Rust. Period.
Rationale
I've seen many, many benchmarking tools. However, no one realizes that we need simplicity to simplify development and increase productivity.
devtimer
provides a very compact yet complete benchmarking suite for code written in Rust.
It makes use of the standard library only to provide benchmark operations.
You can either use it for benchmarking a single operation or you can use it for
running an operation multiple times and finding the min, max and average
execution times. Since this crate has no external dependencies, it is small,
fast and does exactly what it claims to. Happy benchmarking!
Usage
Add this to your cargo.toml
:
= "*"
Then add this line to your source file (i.e main.rs
or lib.rs
or where you need to use it):
use DevTime;
Example usage
Simple usage
Let's say there are two functions called very_long_operation()
and another_op()
that take a very long time to execute. Then we can time it's execution as shown below:
Advanced Usage (for 2.0.0
and up)
use DevTime;
Timing functions available (names are self explanatory):
time_in_secs()
-> Returns the number of seconds the operation tooktime_in_millis()
-> Returns the number of milliseconds the operation tooktime_in_micros()
-> Returns the number of microseconds the operation tooktime_in_nanos()
-> Return the number of nanoseconds the operation took
See the full docs here.
Why are there no tests?
Well, there would be no possible test that I can think of that'd run uniformly across all systems. If I did something like:
let mut timer = new;
timer.start;
sleep;
timer.stop;
assert_eq!;
It can easily fail (and has failed) as system calls can take time and the time for them will differ across every system. This will necessarily pass on all systems, but when compared on a microsecond or nanosecond level, the tests have failed multiple times. Hence I decided to omit all tests from this crate.
License
This project is licensed under the Apache-2.0 License. Keep coding and benchmarking!