commit
8ef864fb39
|
@ -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)
|
||||||
|
.map(|_| {
|
||||||
let rando_keypair = generate_keypair();
|
let rando_keypair = generate_keypair();
|
||||||
let rando_pubkey = get_pubkey(&rando_keypair);
|
let rando_pubkey = get_pubkey(&rando_keypair);
|
||||||
let sig = sign_transaction_data(&one, &alice_keypair, &rando_pubkey);
|
let sig = sign_transaction_data(&one, &alice_keypair, &rando_pubkey);
|
||||||
(rando_pubkey, sig)
|
(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);
|
||||||
|
|
Loading…
Reference in New Issue