Files
solana/sdk/benches/slot_history.rs
mergify[bot] 69b3f10207 move Account to solana-sdk (bp #13198) (#13269)
* move Account to solana-sdk (#13198)

(cherry picked from commit c458d4b213)

# Conflicts:
#	programs/bpf/benches/bpf_loader.rs

* resolve conflicts

Co-authored-by: Jack May <jack@solana.com>
2020-10-29 19:16:52 +00:00

32 lines
671 B
Rust

#![feature(test)]
extern crate test;
use solana_sdk::{
account::{create_account, from_account},
slot_history::SlotHistory,
};
use test::Bencher;
#[bench]
fn bench_to_from_account(b: &mut Bencher) {
let mut slot_history = SlotHistory::default();
b.iter(|| {
let account = create_account(&slot_history, 0);
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;
}
});
}