3 releases

Uses old Rust 2015

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

#14 in #measure-time

Download history 838/week @ 2024-05-22 838/week @ 2024-05-29 1294/week @ 2024-06-05 982/week @ 2024-06-12 1080/week @ 2024-06-19 903/week @ 2024-06-26 916/week @ 2024-07-03 835/week @ 2024-07-10 1083/week @ 2024-07-17 1411/week @ 2024-07-24 1737/week @ 2024-07-31 2049/week @ 2024-08-07 1890/week @ 2024-08-14 1779/week @ 2024-08-21 2447/week @ 2024-08-28 1776/week @ 2024-09-04

8,160 downloads per month
Used in 28 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