solana/benches/ledger.rs

28 lines
876 B
Rust
Raw Normal View History

#![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;
extern crate test;
2018-07-10 19:33:16 -07:00
use solana::entry::reconstruct_entries_from_blobs;
use solana::ledger::{next_entries, Block};
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-11-29 16:18:47 -08:00
use solana_sdk::transaction::Transaction;
use test::Bencher;
2018-07-10 19:33:16 -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();
assert_eq!(reconstruct_entries_from_blobs(blobs).unwrap().0, entries);
2018-07-10 19:33:16 -07:00
});
}