Advertisement
frostblooded

Untitled

Apr 24th, 2020
1,213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.74 KB | None | 0 0
  1. use criterion::*;
  2.  
  3. fn calc_series_no_threads(n: u64) -> BigNum {
  4.     // ...
  5. }
  6.  
  7. fn calc_series_with_threads(n: u64) -> BigNum {
  8.     // ...
  9. }
  10.  
  11. fn calc_series_benchmark(c: &mut Criterion) {
  12.     const SAMPLE_SIZE: usize = 10;
  13.     let mut group = c.benchmark_group("calc series");
  14.     let keypoints = (25..=200).step_by(25);
  15.  
  16.     for i in keypoints {
  17.         group.bench_function(BenchmarkId::new("no threads", i), |b| {
  18.             b.iter(|| calc_series_no_threads(i))
  19.         });
  20.         group.bench_function(BenchmarkId::new("with threads", i), |b| {
  21.             b.iter(|| calc_series_with_threads(i))
  22.         });
  23.     }
  24.  
  25.     group.sample_size(SAMPLE_SIZE);
  26. }
  27.  
  28. criterion_group!(benches, calc_series_benchmark);
  29. criterion_main!(benches);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement