3 releases

Uses old Rust 2015

0.1.2 Apr 3, 2017
0.1.1 Apr 1, 2017
0.1.0 Apr 1, 2017

#18 in #measure-time

Download history 2132/week @ 2024-08-26 2478/week @ 2024-09-02 1447/week @ 2024-09-09 1288/week @ 2024-09-16 1422/week @ 2024-09-23 1041/week @ 2024-09-30 1095/week @ 2024-10-07 1416/week @ 2024-10-14 1529/week @ 2024-10-21 1236/week @ 2024-10-28 1188/week @ 2024-11-04 1363/week @ 2024-11-11 1463/week @ 2024-11-18 1338/week @ 2024-11-25 2267/week @ 2024-12-02 2309/week @ 2024-12-09

7,482 downloads per month
Used in 33 crates (4 directly)

MIT license

7KB
115 lines

Time a block of Rust code

Build Status Docs crates.io

[dependencies]
elapsed = "0.1"
extern crate elapsed;
use elapsed::measure_time;

fn main() {
    let (elapsed, sum) = measure_time(|| {
        (0..10_000).sum::<u64>()
    });
    println!("elapsed = {}", elapsed);
    println!("sum = {}", sum);

    // Prints
    // elapsed = 227.81 μs
    // sum = 49995000
}

Inspired by measureTimeMillis in Kotlin.

No runtime deps