x86/x86_64 time-stamp-counter (TSC) based timer

![Travis-CI Status] ![Appveyor Status] ![Latest Version] ![docs]

API docs of the tsc crate master branch

This library provides a time-stamp counter (TSC) based timer for micro benchmarking:

```rust // The function we want to time: pub fn fibonacci(n: u64) -> u64 { match n { 0 | 1 => 1, n => fibonacci(n - 1) + fibonacci(n - 2), } }

// Non-invariant TSCs might produce unreliable results: assert!(hasinvarianttsc(), "The TSC is not invariant!");

let (duration, result) = Duration::span(|| blackbox(fibonacci(blackbox(8))));

assert_eq!(result, 34);

println!("Reference cycle count: {} cycles.", duration.cycles()); //! // On my machine prints: "Reference cycle count: 951 cycles." ```

Notes

License

This project is licensed under either of

at your option.

Contributing

We welcome all people who want to contribute.

Contributions in any form (issues, pull requests, etc.) to this project must adhere to Rust's [Code of Conduct].

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in tsc by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.