2018-08-22 07:57:07 -07:00
|
|
|
#![feature(test)]
|
2018-12-08 21:44:20 -08:00
|
|
|
|
2018-08-22 07:57:07 -07:00
|
|
|
extern crate test;
|
2018-07-10 19:33:16 -07:00
|
|
|
|
2019-01-09 14:33:44 -08:00
|
|
|
use solana::entry::{next_entries, reconstruct_entries_from_blobs, EntrySlice};
|
2018-11-16 08:04:46 -08:00
|
|
|
use solana_sdk::hash::{hash, Hash};
|
2018-12-03 10:26:28 -08:00
|
|
|
use solana_sdk::signature::{Keypair, KeypairUtil};
|
2018-12-04 15:37:11 -08:00
|
|
|
use solana_sdk::system_transaction::SystemTransaction;
|
2018-08-22 07:57:07 -07:00
|
|
|
use test::Bencher;
|
2018-07-10 19:33:16 -07:00
|
|
|
|
2018-08-22 07:57:07 -07:00
|
|
|
#[bench]
|
2018-07-10 19:33:16 -07:00
|
|
|
fn bench_block_to_blobs_to_block(bencher: &mut Bencher) {
|
|
|
|
let zero = Hash::default();
|
2018-08-01 11:23:52 -07:00
|
|
|
let one = hash(&zero.as_ref());
|
2018-08-09 07:56:04 -07:00
|
|
|
let keypair = Keypair::new();
|
2019-02-01 07:36:35 -08:00
|
|
|
let tx0 = SystemTransaction::new_move(&keypair, keypair.pubkey(), 1, one, 0);
|
2018-07-10 19:33:16 -07:00
|
|
|
let transactions = vec![tx0; 10];
|
|
|
|
let entries = next_entries(&zero, 1, transactions);
|
|
|
|
|
|
|
|
bencher.iter(|| {
|
2018-09-24 10:20:58 -07:00
|
|
|
let blobs = entries.to_blobs();
|
2018-11-12 12:41:19 -08:00
|
|
|
assert_eq!(reconstruct_entries_from_blobs(blobs).unwrap().0, entries);
|
2018-07-10 19:33:16 -07:00
|
|
|
});
|
|
|
|
}
|