Mercurial > lbo > hg > time_test
view src/lib.rs @ 1:d4a954e8992a
Add more info to Cargo.toml
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Sat, 02 Sep 2017 19:39:59 +0200 |
parents | 95fcaa3adf3b |
children | c21d8b7b61cb |
line wrap: on
line source
use std::io::{self, Write}; extern crate time; /// TestTimer allows to easily time tests. It's recommended to use the time_test!() macro. pub struct TestTimer(time::Timespec); impl TestTimer { pub fn new() -> TestTimer { TestTimer(time::get_time()) } } impl Drop for TestTimer { fn drop(&mut self) { write!(io::stderr(), "(took {}) ", time::get_time() - self.0).is_ok(); } } #[macro_export] macro_rules! time_test { () => { use time_test::TestTimer; let _tt = TestTimer::new(); } }