| 1 | A lightweight benchmarking library which: |
| 2 | |
| 3 | * uses linear regression to screen off sources of constant error; |
| 4 | * handles benchmarks which must mutate some state; |
| 5 | * has a very simple API! |
| 6 | |
| 7 | ```rust |
| 8 | use easybench::{bench,bench_env}; |
| 9 | |
| 10 | // Simple benchmarks are performed with `bench`. |
| 11 | println!("fib 200: {}", bench(|| fib(200) )); |
| 12 | println!("fib 500: {}", bench(|| fib(500) )); |
| 13 | |
| 14 | // If a function needs to mutate some state, use `bench_env`. |
| 15 | println!("reverse: {}", bench_env(vec![1,2,3], |xs| xs.reverse())); |
| 16 | println!("sort: {}", bench_env(vec![1,2,3], |xs| xs.sort())); |
| 17 | ``` |
| 18 | |
| 19 | Running the above yields the following: |
| 20 | |
| 21 | ```none |
| 22 | fib 200: 38 ns (R²=1.000, 26053498 iterations in 155 samples) |
| 23 | fib 500: 109 ns (R²=1.000, 9131585 iterations in 144 samples) |
| 24 | reverse: 3 ns (R²=0.998, 23684997 iterations in 154 samples) |
| 25 | sort: 3 ns (R²=0.999, 23684997 iterations in 154 samples) |
| 26 | ``` |
| 27 | |
| 28 | ## License |
| 29 | |
| 30 | Licensed under either of |
| 31 | |
| 32 | * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or |
| 33 | http://www.apache.org/licenses/LICENSE-2.0) |
| 34 | * MIT license ([LICENSE-MIT](LICENSE-MIT) or |
| 35 | http://opensource.org/licenses/MIT) |
| 36 | |
| 37 | at your option. |
| 38 | |
| 39 | ### Contribution |
| 40 | |
| 41 | Unless you explicitly state otherwise, any contribution intentionally submitted |
| 42 | for inclusion in the work by you, as defined in the Apache-2.0 license, shall |
| 43 | be dual licensed as above, without any additional terms or conditions. |