Add bench for StatusCache::slot_deltas() (#26123)
This commit is contained in:
parent
faa6c32162
commit
97bd81a32b
|
@ -1,10 +1,9 @@
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
|
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
use {
|
use {
|
||||||
bincode::serialize,
|
bincode::serialize,
|
||||||
solana_runtime::status_cache::*,
|
solana_runtime::{bank::BankStatusCache, status_cache::*},
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
hash::{hash, Hash},
|
hash::{hash, Hash},
|
||||||
signature::Signature,
|
signature::Signature,
|
||||||
|
@ -12,10 +11,8 @@ use {
|
||||||
test::Bencher,
|
test::Bencher,
|
||||||
};
|
};
|
||||||
|
|
||||||
type BankStatusCache = StatusCache<()>;
|
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn test_statuscache_serialize(bencher: &mut Bencher) {
|
fn bench_status_cache_serialize(bencher: &mut Bencher) {
|
||||||
let mut status_cache = BankStatusCache::default();
|
let mut status_cache = BankStatusCache::default();
|
||||||
status_cache.add_root(0);
|
status_cache.add_root(0);
|
||||||
status_cache.clear();
|
status_cache.clear();
|
||||||
|
@ -28,10 +25,25 @@ fn test_statuscache_serialize(bencher: &mut Bencher) {
|
||||||
id = hash(id.as_ref());
|
id = hash(id.as_ref());
|
||||||
sigbytes.extend(id.as_ref());
|
sigbytes.extend(id.as_ref());
|
||||||
let sig = Signature::new(&sigbytes);
|
let sig = Signature::new(&sigbytes);
|
||||||
status_cache.insert(&blockhash, &sig, 0, ());
|
status_cache.insert(&blockhash, &sig, 0, Ok(()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bencher.iter(|| {
|
bencher.iter(|| {
|
||||||
let _ = serialize(&status_cache.slot_deltas(&[0])).unwrap();
|
let _ = serialize(&status_cache.slot_deltas(&[0])).unwrap();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn bench_status_cache_slot_deltas(bencher: &mut Bencher) {
|
||||||
|
let mut status_cache = BankStatusCache::default();
|
||||||
|
|
||||||
|
// fill the status cache
|
||||||
|
let slots: Vec<_> = (42..).take(MAX_CACHE_ENTRIES).collect();
|
||||||
|
for slot in &slots {
|
||||||
|
for _ in 0..5 {
|
||||||
|
status_cache.insert(&Hash::new_unique(), Hash::new_unique(), *slot, Ok(()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bencher.iter(|| test::black_box(status_cache.slot_deltas(&slots)));
|
||||||
|
}
|
||||||
|
|
|
@ -250,7 +250,7 @@ impl RentDebits {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type BankStatusCache = StatusCache<Result<()>>;
|
pub type BankStatusCache = StatusCache<Result<()>>;
|
||||||
#[frozen_abi(digest = "2YZk2K45HmmAafmxPJnYVXyQ7uA7WuBrRkpwrCawdK31")]
|
#[frozen_abi(digest = "2YZk2K45HmmAafmxPJnYVXyQ7uA7WuBrRkpwrCawdK31")]
|
||||||
pub type BankSlotDelta = SlotDelta<Result<()>>;
|
pub type BankSlotDelta = SlotDelta<Result<()>>;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue