#long #how #macro #cases #measure

time-test

Measure how long your test cases take with one simple macro

5 releases

0.2.3 Feb 23, 2022
0.2.2 Oct 12, 2019
0.2.1 Sep 3, 2017
0.2.0 Sep 2, 2017
0.1.0 Sep 2, 2017

#391 in Testing

Download history 461/week @ 2023-11-27 280/week @ 2023-12-04 394/week @ 2023-12-11 523/week @ 2023-12-18 313/week @ 2023-12-25 525/week @ 2024-01-01 520/week @ 2024-01-08 529/week @ 2024-01-15 803/week @ 2024-01-22 575/week @ 2024-01-29 452/week @ 2024-02-05 972/week @ 2024-02-12 485/week @ 2024-02-19 739/week @ 2024-02-26 277/week @ 2024-03-04 67/week @ 2024-03-11

1,594 downloads per month
Used in 12 crates

MIT license

5KB

time_test

time_test is a super simple crate that you can use to easily obtain how long your tests took to run. Using it is simple (see example/ for an example use case):

#[macro_use]
extern crate time_test;

#[cfg(test)]
mod tests {
    #[test]
    fn my_test() {
        time_test!();

        println!("hello world");

        {
            time_test!("sub-assert 1");
            assert!(true);
        }
        assert_eq!(1, 1);
    }
}

Adding the time_test!() macro to the line in your test from which you want to measure the test duration will result in the duration that the test has taken being shown in the test result line:

$ # 1 test thread so that the output is not garbled.
$ cargo test -- --test-threads=1

    Finished dev [unoptimized + debuginfo] target(s) in 0.78 secs
     Running target/debug/deps/example-a84426a5de188514

running 1 test
test example::tests::my_test ... (sub-assert 1 took PT0.000002421S) (took PT0.000004178S) ok

lib.rs:

time_test is a super simple crate that you can use to easily obtain how long your tests took to run. Using it is simple (see example/ for an example use case):

#[macro_use] extern crate time_test;

#[cfg(test)]
mod tests {
    #[test]
    fn my_test() {
        time_test!();

        println!("hello world");

        {
            time_test!("sub-assert 1");
            assert!(true);
        }
        assert_eq!(1, 1);
    }
}

Adding the time_test!() macro to the line in your test from which you want to measure the test duration will result in the duration that the test has taken being shown in the test result line:

$ # 1 test thread so that the output is not garbled.
$ cargo test -- --test-threads=1

    Finished dev [unoptimized + debuginfo] target(s) in 0.78 secs
     Running target/debug/deps/example-a84426a5de188514

running 1 test
test example::tests::my_test ... (sub-assert 1 took PT0.000002421S) (took PT0.000004178S) ok

Dependencies

~0.6–1MB
~14K SLoC