solana/benches/ledger.rs

27 lines
835 B
Rust
Raw Normal View History

#![feature(test)]
2018-07-10 19:33:16 -07:00
extern crate solana;
extern crate test;
2018-07-10 19:33:16 -07:00
use solana::entry::reconstruct_entries_from_blobs;
2018-07-10 19:33:16 -07:00
use solana::hash::{hash, Hash};
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-07-10 19:33:16 -07:00
use solana::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
});
}