Benchmark for key ordering

This commit is contained in:
Dr Maxim Orlovsky 2021-06-20 17:58:50 +02:00 committed by Tobin C. Harding
parent 999d165c68
commit 0faf404f0e
1 changed files with 21 additions and 0 deletions

View File

@ -2204,3 +2204,24 @@ mod test {
assert_eq!(got, want)
}
}
#[cfg(all(test, feature = "unstable"))]
mod benches {
use test::Bencher;
use std::collections::BTreeSet;
use crate::PublicKey;
use crate::constants::GENERATOR_X;
#[bench]
fn bench_pk_ordering(b: &mut Bencher) {
let mut map = BTreeSet::new();
let mut g_slice = [02u8; 33];
g_slice[1..].copy_from_slice(&GENERATOR_X);
let g = PublicKey::from_slice(&g_slice).unwrap();
let mut pk = g;
b.iter(|| {
map.insert(pk);
pk = pk.combine(&pk).unwrap();
})
}
}