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

..--

benches/23-Nov-2023-572471

ci/23-Nov-2023-6652

patches/23-Nov-2023-1615

src/23-Nov-2023-13,34710,170

tests/23-Nov-2023-595491

.cargo_vcs_info.jsonD23-Nov-202374 65

.editorconfigD23-Nov-2023131 97

.gitignoreD23-Nov-202340 64

.travis.ymlD23-Nov-20231.6 KiB8876

Android.bpD23-Nov-20233.9 KiB126121

CHANGELOG.mdD23-Nov-202321.2 KiB410358

CONTRIBUTING.mdD23-Nov-20232.9 KiB7748

Cargo.tomlD23-Nov-20233.1 KiB152120

Cargo.toml.origD23-Nov-20233.1 KiB9781

LICENSED23-Nov-202310.6 KiB202169

LICENSE-APACHED23-Nov-202310.6 KiB202169

LICENSE-MITD23-Nov-20231 KiB2622

METADATAD23-Nov-2023387 2019

MODULE_LICENSE_APACHE2D23-Nov-20230

OWNERSD23-Nov-202340 21

README.mdD23-Nov-20236.2 KiB146106

appveyor.ymlD23-Nov-2023847 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  - [Criterion.rs Extensions](#criterionrs-extensions)
44
45### Features
46
47- __Statistics__: Statistical analysis detects if, and by how much, performance has changed since the last benchmark run
48- __Charts__: Uses [gnuplot](http://www.gnuplot.info/) to generate detailed graphs of benchmark results
49- __Stable-compatible__: Benchmark your code without installing nightly Rust
50
51### Quickstart
52
53In order to generate plots, you must have [gnuplot](http://www.gnuplot.info/) installed. See the gnuplot website for installation instructions. See [Compatibility Policy](#compatibility-policy) for details on the minimum supported Rust version.
54
55To start with Criterion.<span></span>rs, add the following to your `Cargo.toml` file:
56
57```toml
58[dev-dependencies]
59criterion = "0.3"
60
61[[bench]]
62name = "my_benchmark"
63harness = false
64```
65
66Next, define a benchmark by creating a file at `$PROJECT/benches/my_benchmark.rs` with the following contents:
67
68```rust
69use criterion::{black_box, criterion_group, criterion_main, Criterion};
70
71fn fibonacci(n: u64) -> u64 {
72    match n {
73        0 => 1,
74        1 => 1,
75        n => fibonacci(n-1) + fibonacci(n-2),
76    }
77}
78
79fn criterion_benchmark(c: &mut Criterion) {
80    c.bench_function("fib 20", |b| b.iter(|| fibonacci(black_box(20))));
81}
82
83criterion_group!(benches, criterion_benchmark);
84criterion_main!(benches);
85```
86
87Finally, run this benchmark with `cargo bench`. You should see output similar to the following:
88
89```
90     Running target/release/deps/example-423eedc43b2b3a93
91fib 20                  time:   [26.029 us 26.251 us 26.505 us]
92Found 11 outliers among 99 measurements (11.11%)
93  6 (6.06%) high mild
94  5 (5.05%) high severe
95```
96
97See the [Getting Started](https://bheisler.github.io/criterion.rs/book/getting_started.html) guide for more details.
98
99### Goals
100
101The 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.
102
103### Contributing
104
105First, thank you for contributing.
106
107One 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.
108
109Code or documentation improvements in the form of pull requests are also welcome. If you're not
110sure what to work on, try checking the
111[Beginner label](https://github.com/bheisler/criterion.rs/issues?q=is%3Aissue+is%3Aopen+label%3ABeginner).
112
113If your issues or pull requests have no response after a few days, feel free to ping me (@bheisler).
114
115For more details, see the [CONTRIBUTING.md file](https://github.com/bheisler/criterion.rs/blob/master/CONTRIBUTING.md).
116
117### Compatibility Policy
118
119Criterion.<span></span>rs supports the last three stable minor releases of Rust. At time of
120writing, this means Rust 1.40 or later. Older versions may work, but are not tested or guaranteed.
121
122Currently, the oldest version of Rust believed to work is 1.39. Future versions of Criterion.<span></span>rs may
123break support for such old versions, and this will not be considered a breaking change. If you
124require Criterion.<span></span>rs to work on old versions of Rust, you will need to stick to a
125specific patch version of Criterion.<span></span>rs.
126
127### Maintenance
128
129Criterion.<span></span>rs was originally created by Jorge Aparicio (@japaric) and is currently being maintained by Brook Heisler (@bheisler).
130
131### License
132
133Criterion.<span></span>rs is dual licensed under the Apache 2.0 license and the MIT license.
134
135### Related Projects
136
137- [bencher](https://github.com/bluss/bencher) - A port of the libtest benchmark runner to stable Rust
138- [criterion](http://www.serpentine.com/criterion/) - The Haskell microbenchmarking library that inspired Criterion.<span></span>rs
139- [cargo-benchcmp](https://github.com/BurntSushi/cargo-benchcmp) - Cargo subcommand to compare the output of two libtest or bencher benchmark runs
140- [cargo-flamegraph](https://github.com/ferrous-systems/flamegraph) - Cargo subcommand to profile an executable and produce a flamegraph
141
142### Criterion.rs Extensions
143
144- [criterion-cycles-per-byte](https://crates.io/crates/criterion-cycles-per-byte) - A custom-measurement plugin that counts the number of CPU cycles used by the benchmark
145- [criterion-perf-events](https://crates.io/crates/criterion-perf-events) - A custom-measurement plugin that counts perf events created by the benchmark
146