Merge pull request #37 from garious/split-benchmark

Split benchmark
This commit is contained in:
Greg Fitzgerald 2018-03-03 12:13:54 -07:00 committed by GitHub
commit 8ef864fb39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 8 deletions

View File

@ -22,19 +22,44 @@ fn main() {
let one = 1; let one = 1;
println!("Signing transactions..."); println!("Signing transactions...");
let now = Instant::now(); let now = Instant::now();
let sigs = (0..txs).map(|_| { let sigs: Vec<(_, _)> = (0..txs)
let rando_keypair = generate_keypair(); .map(|_| {
let rando_pubkey = get_pubkey(&rando_keypair); let rando_keypair = generate_keypair();
let sig = sign_transaction_data(&one, &alice_keypair, &rando_pubkey); let rando_pubkey = get_pubkey(&rando_keypair);
(rando_pubkey, sig) let sig = sign_transaction_data(&one, &alice_keypair, &rando_pubkey);
}); (rando_pubkey, sig)
})
.collect();
let duration = now.elapsed(); let duration = now.elapsed();
let ns = duration.as_secs() * 1_000_000_000 + duration.subsec_nanos() as u64; let ns = duration.as_secs() * 1_000_000_000 + duration.subsec_nanos() as u64;
let bsps = txs as f64 / ns as f64; let bsps = txs as f64 / ns as f64;
let nsps = ns as f64 / txs as f64; let nsps = ns as f64 / txs as f64;
println!( println!(
"Done. {} billion signatures per second, {}ns per signature", "Done. {} thousand signatures per second, {}us per signature",
bsps, nsps bsps * 1_000_000_f64,
nsps / 1_000_f64
);
println!("Verify signatures...");
use silk::event::{verify_event, Event};
let now = Instant::now();
for &(k, s) in &sigs {
let e = Event::Transaction {
from: Some(alice_pubkey),
to: k,
data: one,
sig: s,
};
assert!(verify_event(&e));
}
let duration = now.elapsed();
let ns = duration.as_secs() * 1_000_000_000 + duration.subsec_nanos() as u64;
let bsvps = txs as f64 / ns as f64;
let nspsv = ns as f64 / txs as f64;
println!(
"Done. {} thousand signature verifications per second, {}us per signature verification",
bsvps * 1_000_000_f64,
nspsv / 1_000_f64
); );
println!("Transferring 1 unit {} times...", txs); println!("Transferring 1 unit {} times...", txs);