3 releases

Uses old Rust 2015

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

#19 in #measure-time

Download history 505/week @ 2023-11-04 512/week @ 2023-11-11 498/week @ 2023-11-18 624/week @ 2023-11-25 693/week @ 2023-12-02 501/week @ 2023-12-09 813/week @ 2023-12-16 519/week @ 2023-12-23 589/week @ 2023-12-30 456/week @ 2024-01-06 638/week @ 2024-01-13 690/week @ 2024-01-20 784/week @ 2024-01-27 656/week @ 2024-02-03 785/week @ 2024-02-10 815/week @ 2024-02-17

3,140 downloads per month
Used in 14 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