Registry / testing / criterion

criterion

JSON →
library0.8.2rscratesunverified

Statistics-driven micro-benchmarking library

# Cargo.toml [dependencies] criterion = "0.8.2"
INSTALL
IMPORT
SIG · CRITERION
C
criterion
testingrustv0.8.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Criterion
use criterion::Criterion;

Benchmarks the Fibonacci function.

use criterion::{Criterion, criterion_group, criterion_main}; fn fibonacci(n: u64) -> u64 { match n { 0 => 0, 1 => 1, _ => fibonacci(n-1) + fibonacci(n-2), } } fn bench_fib(c: &mut Criterion) { c.bench_function("fib 20", |b| b.iter(|| fibonacci(20))); } criterion_group!(benches, bench_fib); criterion_main!(benches);
Debug
Known issues
gotchaCriterion requires nightly Rust for some features (e.g., black_box).
fix
Use stable Rust; black_box is available on stable since 1.66.
affects: <0.5.0
Upgrade
Version history
0.8.2latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
criterion — cargo add criterion · libregistry