solana/sdk/benches/slot_history.rs

34 lines
710 B
Rust
Raw Normal View History

#![feature(test)]
extern crate test;
use {
solana_sdk::{
account::{create_account_for_test, from_account},
slot_history::SlotHistory,
},
test::Bencher,
2020-10-28 22:01:07 -07:00
};
#[bench]
fn bench_to_from_account(b: &mut Bencher) {
let mut slot_history = SlotHistory::default();
b.iter(|| {
let account = create_account_for_test(&slot_history);
2021-03-09 13:06:07 -08:00
slot_history = from_account::<SlotHistory, _>(&account).unwrap();
});
}
#[bench]
fn bench_slot_history_add_new(b: &mut Bencher) {
let mut slot_history = SlotHistory::default();
let mut slot = 0;
b.iter(|| {
for _ in 0..5 {
slot_history.add(slot);
slot += 100_000;
}
});
}