Skip to content

Commit

Permalink
Merge pull request AleoNet#1768 from ljedrz/testnet3_benchmark_cipher…
Browse files Browse the repository at this point in the history
…text_lookups

Add a ciphertext_lookup_by_commitment benchmark
  • Loading branch information
howardwu authored May 25, 2022
2 parents 0ac4455 + 4626db4 commit abf4b35
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions storage/benches/lookups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,28 @@ fn lookups(c: &mut Criterion) {
})
});

c.bench_function("txs_lookup_by_commitment", |b| {
let tx_commitments = ledger
.storage()
.open_map::<<CurrentNetwork as Network>::Commitment, <CurrentNetwork as Network>::TransitionID>(MapId::Commitments)
.unwrap()
.keys()
.collect::<Vec<_>>();
// Commitments are used for multiple lookups.
let tx_commitments = ledger
.storage()
.open_map::<<CurrentNetwork as Network>::Commitment, <CurrentNetwork as Network>::TransitionID>(MapId::Commitments)
.unwrap()
.keys()
.collect::<Vec<_>>();

c.bench_function("txs_lookup_by_commitment", |b| {
b.iter(|| {
let id = tx_commitments.choose(&mut rng).unwrap();
ledger.contains_commitment(id).expect("Lookup by commitment failed");
})
});

c.bench_function("ciphertext_lookup_by_commitment", |b| {
b.iter(|| {
let id = tx_commitments.choose(&mut rng).unwrap();
ledger.get_ciphertext(id).expect("Lookup by commitment failed");
})
});

c.bench_function("txs_lookup_by_serial_number", |b| {
let tx_serial_numbers = ledger
.storage()
Expand Down

0 comments on commit abf4b35

Please sign in to comment.