Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use criterion::*;
- fn calc_series_no_threads(n: u64) -> BigNum {
- // ...
- }
- fn calc_series_with_threads(n: u64) -> BigNum {
- // ...
- }
- fn calc_series_benchmark(c: &mut Criterion) {
- const SAMPLE_SIZE: usize = 10;
- let mut group = c.benchmark_group("calc series");
- let keypoints = (25..=200).step_by(25);
- for i in keypoints {
- group.bench_function(BenchmarkId::new("no threads", i), |b| {
- b.iter(|| calc_series_no_threads(i))
- });
- group.bench_function(BenchmarkId::new("with threads", i), |b| {
- b.iter(|| calc_series_with_threads(i))
- });
- }
- group.sample_size(SAMPLE_SIZE);
- }
- criterion_group!(benches, calc_series_benchmark);
- criterion_main!(benches);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement