2018-08-22 07:57:07 -07:00
|
|
|
#![feature(test)]
|
2018-07-10 19:33:16 -07:00
|
|
|
extern crate solana;
|
2018-11-16 08:04:46 -08:00
|
|
|
extern crate solana_sdk;
|
2018-08-22 07:57:07 -07:00
|
|
|
extern crate test;
|
2018-07-10 19:33:16 -07:00
|
|
|
|
2018-11-12 12:41:19 -08:00
|
|
|
use solana::entry::reconstruct_entries_from_blobs;
|
|
|
|
use solana::ledger::{next_entries, Block};
|
2018-08-09 07:56:04 -07:00
|
|
|
use solana::signature::{Keypair, KeypairUtil};
|
2018-09-26 17:21:43 -07:00
|
|
|
use solana::system_transaction::SystemTransaction;
|
2018-11-16 08:04:46 -08:00
|
|
|
use solana_sdk::hash::{hash, Hash};
|
2018-11-29 16:18:47 -08:00
|
|
|
use solana_sdk::transaction::Transaction;
|
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();
|
2018-09-26 17:21:43 -07:00
|
|
|
let tx0 = Transaction::system_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
|
|
|
});
|
|
|
|
}
|