2020-01-10 16:08:30 +00:00
|
|
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
|
|
|
|
2020-01-21 09:09:20 +00:00
|
|
|
use sharks::Sharks;
|
|
|
|
|
|
|
|
fn dealer(c: &mut Criterion) {
|
|
|
|
let sharks = Sharks(255);
|
|
|
|
let mut dealer = sharks.dealer(&[1]);
|
2020-01-10 16:08:30 +00:00
|
|
|
|
2020-01-21 09:09:20 +00:00
|
|
|
c.bench_function("obtain_shares_dealer", |b| {
|
|
|
|
b.iter(|| sharks.dealer(black_box(&[1])))
|
2020-01-13 10:42:59 +00:00
|
|
|
});
|
2020-01-21 09:09:20 +00:00
|
|
|
c.bench_function("step_shares_dealer", |b| b.iter(|| dealer.next()));
|
2020-01-10 16:08:30 +00:00
|
|
|
}
|
|
|
|
|
2020-01-21 09:09:20 +00:00
|
|
|
fn recover(c: &mut Criterion) {
|
|
|
|
let sharks = Sharks(255);
|
|
|
|
let shares = sharks.dealer(&[1]).take(255).collect();
|
2020-01-10 16:08:30 +00:00
|
|
|
|
2020-01-13 10:42:59 +00:00
|
|
|
c.bench_function("recover_secret", |b| {
|
2020-01-21 09:09:20 +00:00
|
|
|
b.iter(|| sharks.recover(black_box(&shares)))
|
2020-01-13 10:42:59 +00:00
|
|
|
});
|
2020-01-10 16:08:30 +00:00
|
|
|
}
|
|
|
|
|
2020-01-21 09:09:20 +00:00
|
|
|
criterion_group!(benches, dealer, recover);
|
2020-01-10 16:08:30 +00:00
|
|
|
criterion_main!(benches);
|