GitXplorerGitXplorer
g

timeit

public
16 stars
4 forks
5 issues

Commits

List of commits on branch master.
Unverified
8a6efb763dc1c4d626ae8e493ce14a0e5a6ebfba

DOC: Added crates.io badge

ggustavla committed 9 years ago
Unverified
058727f89321dc5df44912d8c2030b4c3de97b8d

REL: 0.1.2

ggustavla committed 10 years ago
Unverified
f31276c9cb0b2957996cd7d49ae569bc0a982787

Fixed critical import bug

ggustavla committed 10 years ago
Unverified
4efd56eeb62bc34abadf673260f732c44462081e

REL: 0.1.1

ggustavla committed 10 years ago
Unverified
f67f918b7ffc733a5d14f3084373e692ea02de33

Fixed bug causing only one loop for short blocks

ggustavla committed 10 years ago
Unverified
9c13d087879146bd24fb84e14affe8655d5dbaf4

Added link to timeit

ggustavla committed 10 years ago

README

The README file for this repository.

Crates.io

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);
    }
});