diff --git a/src/bin/client-demo.rs b/src/bin/client-demo.rs index ab5f1a48e2..e40d837677 100644 --- a/src/bin/client-demo.rs +++ b/src/bin/client-demo.rs @@ -22,19 +22,44 @@ fn main() { let one = 1; println!("Signing transactions..."); let now = Instant::now(); - let sigs = (0..txs).map(|_| { - let rando_keypair = generate_keypair(); - let rando_pubkey = get_pubkey(&rando_keypair); - let sig = sign_transaction_data(&one, &alice_keypair, &rando_pubkey); - (rando_pubkey, sig) - }); + let sigs: Vec<(_, _)> = (0..txs) + .map(|_| { + let rando_keypair = generate_keypair(); + let rando_pubkey = get_pubkey(&rando_keypair); + let sig = sign_transaction_data(&one, &alice_keypair, &rando_pubkey); + (rando_pubkey, sig) + }) + .collect(); let duration = now.elapsed(); let ns = duration.as_secs() * 1_000_000_000 + duration.subsec_nanos() as u64; let bsps = txs as f64 / ns as f64; let nsps = ns as f64 / txs as f64; println!( - "Done. {} billion signatures per second, {}ns per signature", - bsps, nsps + "Done. {} thousand signatures per second, {}us per signature", + 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);