• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

benches/H03-May-2022-282233

ci/H03-May-2022-5847

src/H03-May-2022-9,0896,790

tests/H03-May-2022-607485

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D01-Jan-197074 65

.editorconfigH A D26-Jan-2019131 97

.gitignoreH A D26-Jan-201929 43

.travis.ymlH A D26-Jan-20191.6 KiB9483

CHANGELOG.mdH A D09-Apr-201913.1 KiB270233

CONTRIBUTING.mdH A D26-Jan-20192.9 KiB7748

Cargo.tomlH A D01-Jan-19702.4 KiB11890

Cargo.toml.orig-cargoH A D09-Apr-20191.5 KiB6152

LICENSE-APACHEH A D26-Jan-201910.6 KiB202169

LICENSE-MITH A D26-Jan-20191 KiB2622

README.mdH A D09-Apr-20195.7 KiB143104

appveyor.ymlH A D26-Jan-2019847 3025

README.md

1<h1 align="center">Criterion.<span></span>rs</h1>
2
3<div align="center">Statistics-driven Microbenchmarking in Rust</div>
4
5<div align="center">
6	<a href="https://bheisler.github.io/criterion.rs/book/getting_started.html">Getting Started</a>
7    |
8    <a href="https://bheisler.github.io/criterion.rs/book/index.html">User Guide</a>
9    |
10    <a href="https://bheisler.github.io/criterion.rs/criterion/">Master API Docs</a>
11    |
12    <a href="https://docs.rs/crate/criterion/">Released API Docs</a>
13    |
14    <a href="https://github.com/bheisler/criterion.rs/blob/master/CHANGELOG.md">Changelog</a>
15</div>
16
17<div align="center">
18	<a href="https://travis-ci.org/bheisler/criterion.rs">
19        <img src="https://travis-ci.org/bheisler/criterion.rs.svg?branch=master" alt="Travis-CI">
20    </a>
21    |
22    <a href="https://ci.appveyor.com/project/bheisler/criterion-rs-vt9fl">
23        <img src="https://ci.appveyor.com/api/projects/status/4255ads9ctpupcl2?svg=true" alt="Appveyor">
24    </a>
25    |
26    <a href="https://crates.io/crates/criterion">
27        <img src="https://img.shields.io/crates/v/criterion.svg" alt="Crates.io">
28    </a>
29</div>
30
31Criterion.<span></span>rs helps you write fast code by detecting and measuring performance improvements or regressions, even small ones, quickly and accurately. You can optimize with confidence, knowing how each change affects the performance of your code.
32
33## Table of Contents
34- [Table of Contents](#table-of-contents)
35  - [Features](#features)
36  - [Quickstart](#quickstart)
37  - [Goals](#goals)
38  - [Contributing](#contributing)
39  - [Compatibility Policy](#compatibility-policy)
40  - [Maintenance](#maintenance)
41  - [License](#license)
42  - [Related Projects](#related-projects)
43
44### Features
45
46- __Statistics__: Statistical analysis detects if, and by how much, performance has changed since the last benchmark run
47- __Charts__: Uses [gnuplot](http://www.gnuplot.info/) to generate detailed graphs of benchmark results.
48- __Stable-compatible__: Benchmark your code without installing nightly Rust.
49
50### Quickstart
51
52In order to generate plots, you must have [gnuplot](http://www.gnuplot.info/) installed. See the gnuplot website for installation instructions. Criterion.rs also currently requires Rust 1.28 or later (see [Compatibility Policy](#compatibility-policy) for more details).
53
54To start with Criterion.<span></span>rs, add the following to your `Cargo.toml` file:
55
56```toml
57[dev-dependencies]
58criterion = "0.2"
59
60[[bench]]
61name = "my_benchmark"
62harness = false
63```
64
65Next, define a benchmark by creating a file at `$PROJECT/benches/my_benchmark.rs` with the following contents.
66
67```rust
68#[macro_use]
69extern crate criterion;
70
71use criterion::Criterion;
72use criterion::black_box;
73
74fn fibonacci(n: u64) -> u64 {
75    match n {
76        0 => 1,
77        1 => 1,
78        n => fibonacci(n-1) + fibonacci(n-2),
79    }
80}
81
82fn criterion_benchmark(c: &mut Criterion) {
83    c.bench_function("fib 20", |b| b.iter(|| fibonacci(black_box(20))));
84}
85
86criterion_group!(benches, criterion_benchmark);
87criterion_main!(benches);
88```
89
90Finally, run this benchmark with `cargo bench`. You should see output similar to the following:
91
92```
93     Running target/release/deps/example-423eedc43b2b3a93
94fib 20                  time:   [26.029 us 26.251 us 26.505 us]
95Found 11 outliers among 99 measurements (11.11%)
96  6 (6.06%) high mild
97  5 (5.05%) high severe
98```
99
100See the [Getting Started](https://bheisler.github.io/criterion.rs/book/getting_started.html) guide for more details.
101
102### Goals
103
104The primary goal of Criterion.<span></span>rs is to provide a powerful and statistically rigorous tool for measuring the performance of code, preventing performance regressions and accurately measuring optimizations. Additionally, it should be as programmer-friendly as possible and make it easy to create reliable, useful benchmarks, even for programmers without an advanced background in statistics.
105
106### Contributing
107
108First, thank you for contributing.
109
110One great way to contribute to Criterion.<span></span>rs is to use it for your own benchmarking needs and report your experiences, file and comment on issues, etc.
111
112Code or documentation improvements in the form of pull requests are also welcome. If you're not
113sure what to work on, try checking the
114[Beginner label](https://github.com/bheisler/criterion.rs/issues?q=is%3Aissue+is%3Aopen+label%3ABeginner)
115
116If your issues or pull requests have no response after a few days, feel free to ping me (@bheisler)
117
118For more details, see the [CONTRIBUTING.md file](https://github.com/bheisler/criterion.rs/blob/master/CONTRIBUTING.md)
119
120### Compatibility Policy
121
122Criterion.<span></span>rs supports the last three stable minor releases of Rust. At time of
123writing, this means Rust 1.29 or later. Older versions may work, but are not tested or guaranteed.
124
125Currently, the oldest version of Rust believed to work is 1.23. Future versions of Criterion.rs may
126break support for such old versions, and this will not be considered a breaking change. If you
127require Criterion.<span></span>rs to work on old versions of Rust, you will need to stick to a
128specific patch version of Criterion.<span></span>rs.
129
130### Maintenance
131
132Criterion.<span></span>rs was originally created by Jorge Aparicio (@japaric) and is currently being maintained by Brook Heisler (@bheisler).
133
134### License
135
136Criterion.<span></span>rs is dual licensed under the Apache 2.0 license and the MIT license.
137
138### Related Projects
139
140- [bencher](https://github.com/bluss/bencher) - A port of the libtest benchmark runner to stable Rust
141- [criterion](http://www.serpentine.com/criterion/) - The Haskell microbenchmarking library that inspired Criterion.<span></span>rs
142- [cargo-benchcmp](https://github.com/BurntSushi/cargo-benchcmp) - Cargo subcommand to compare the output of two libtest or bencher benchmark runs
143