Add small key derivation benchmarks

This commit is contained in:
Jack Grigg 2021-03-20 18:19:51 +13:00
parent e0a2141888
commit f18ffa63d5
2 changed files with 23 additions and 0 deletions

View File

@ -45,3 +45,7 @@ criterion = "0.3"
[lib]
bench = false
[[bench]]
name = "small"
harness = false

19
benches/small.rs Normal file
View File

@ -0,0 +1,19 @@
use criterion::{criterion_group, criterion_main, Criterion};
use orchard::keys::{FullViewingKey, SpendingKey};
fn key_derivation(c: &mut Criterion) {
// Meaningless random spending key.
let sk = SpendingKey::from_bytes([
0x2e, 0x0f, 0xd6, 0xc0, 0xed, 0x0b, 0xcf, 0xd8, 0x07, 0xf5, 0xdb, 0xff, 0x47, 0x4e, 0xdc,
0x78, 0x8c, 0xe0, 0x09, 0x30, 0x66, 0x10, 0x1e, 0x95, 0x82, 0x87, 0xb1, 0x00, 0x50, 0x9b,
0xf7, 0x9a,
])
.unwrap();
let fvk = FullViewingKey::from(&sk);
c.bench_function("derive_fvk", |b| b.iter(|| FullViewingKey::from(&sk)));
c.bench_function("default_address", |b| b.iter(|| fvk.default_address()));
}
criterion_group!(benches, key_derivation);
criterion_main!(benches);