.buildkite
.github
bench-exchange
bench-streamer
bench-tps
book
chacha-sys
ci
client
core
drone
genesis
gossip
install
keygen
kvstore
ledger-tool
logger
merkle-tree
metrics
multinode-demo
net
netutil
programs
replicator
runtime
benches
accounts.rs
accounts_index.rs
append_vec.rs
bank.rs
bloom.rs
message_processor.rs
status_cache.rs
src
tests
.gitignore
Cargo.toml
scripts
sdk
upload-perf
validator
vote-signer
wallet
.appveyor.yml
.clippy.toml
.codecov.yml
.gitignore
.travis.yml
CONTRIBUTING.md
Cargo.lock
Cargo.toml
LICENSE
README.md
RELEASE.md
fetch-perf-libs.sh
run.sh
34 lines
968 B
Rust
34 lines
968 B
Rust
![]() |
#![feature(test)]
|
||
|
|
||
|
extern crate test;
|
||
|
|
||
|
use bincode::serialize;
|
||
|
use solana_runtime::status_cache::*;
|
||
|
use solana_sdk::hash::{hash, Hash};
|
||
|
use solana_sdk::signature::Signature;
|
||
|
use test::Bencher;
|
||
|
|
||
|
type BankStatusCache = StatusCache<()>;
|
||
|
|
||
|
#[bench]
|
||
|
fn test_statuscache_serialize(bencher: &mut Bencher) {
|
||
|
let mut status_cache = BankStatusCache::default();
|
||
|
status_cache.add_root(0);
|
||
|
status_cache.clear_signatures();
|
||
|
for hash_index in 0..100 {
|
||
|
let blockhash = Hash::new(&vec![hash_index; std::mem::size_of::<Hash>()]);
|
||
|
let mut id = blockhash;
|
||
|
for _ in 0..100 {
|
||
|
id = hash(id.as_ref());
|
||
|
let mut sigbytes = Vec::from(id.as_ref());
|
||
|
id = hash(id.as_ref());
|
||
|
sigbytes.extend(id.as_ref());
|
||
|
let sig = Signature::new(&sigbytes);
|
||
|
status_cache.insert(&blockhash, &sig, 0, ());
|
||
|
}
|
||
|
}
|
||
|
bencher.iter(|| {
|
||
|
let _ = serialize(&status_cache).unwrap();
|
||
|
});
|
||
|
}
|