2019-12-23 12:23:45 -08:00
|
|
|
#![feature(test)]
|
|
|
|
|
|
|
|
extern crate test;
|
2021-12-03 09:00:31 -08:00
|
|
|
use {
|
|
|
|
solana_sdk::{
|
|
|
|
account::{create_account_for_test, from_account},
|
|
|
|
slot_history::SlotHistory,
|
|
|
|
},
|
|
|
|
test::Bencher,
|
2020-10-28 22:01:07 -07:00
|
|
|
};
|
2019-12-23 12:23:45 -08:00
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_to_from_account(b: &mut Bencher) {
|
|
|
|
let mut slot_history = SlotHistory::default();
|
|
|
|
|
|
|
|
b.iter(|| {
|
2021-03-25 15:23:20 +09:00
|
|
|
let account = create_account_for_test(&slot_history);
|
2021-03-09 15:06:07 -06:00
|
|
|
slot_history = from_account::<SlotHistory, _>(&account).unwrap();
|
2019-12-23 12:23:45 -08:00
|
|
|
});
|
|
|
|
}
|
2020-05-22 11:15:16 -07:00
|
|
|
|
|
|
|
#[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);
|
2020-06-09 01:38:14 +01:00
|
|
|
slot += 100_000;
|
2020-05-22 11:15:16 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|