timeit

Crates.iotimeit
lib.rstimeit
version0.1.2
created_at2015-06-27 20:02:11.576746+00
updated_at2015-12-11 23:59:11.698689+00
descriptionTiming macros for Rust modelled after Python's timeit
homepage
repositoryhttps://github.com/gustavla/timeit
max_upload_size
id2479
size4,820
Gustav Larsson (gustavla)

documentation

README

Timeit for Rust

This crate provides macros that make it easy to benchmark blocks of code. It is inspired and named after timeit from Python.

Examples

#[macro_use]
extern crate timeit;

fn main() {
    timeit!({
        let mut x: Vec<u64> = Vec::new();
        for i in 0..1000 {
            x.push(i);
        }
    });
}

This will output something like:

10000 loops: 2.4843 µs

It will determine the number of loops automatically. To run a specified number of loops and save the elapsed time to a variable, use the timeit_loops! macro:

let sec = timeit_loops!(100, {
    let mut x: Vec<u64> = Vec::new();
    for i in 0..1000 {
        x.push(i);
    }
});
Commit count: 0

cargo fmt