2018-08-22 07:57:07 -07:00
|
|
|
#![feature(test)]
|
2018-12-08 21:44:20 -08:00
|
|
|
|
2018-08-22 07:57:07 -07:00
|
|
|
extern crate test;
|
2018-08-01 14:10:39 -07:00
|
|
|
|
2019-11-06 10:52:30 -08:00
|
|
|
use solana_perf::packet::to_packets;
|
2019-11-04 20:13:43 -08:00
|
|
|
use solana_perf::recycler::Recycler;
|
2019-11-06 10:52:30 -08:00
|
|
|
use solana_perf::sigverify;
|
|
|
|
use solana_perf::test_tx::test_tx;
|
2018-08-22 07:57:07 -07:00
|
|
|
use test::Bencher;
|
2018-08-01 14:10:39 -07:00
|
|
|
|
2018-08-22 07:57:07 -07:00
|
|
|
#[bench]
|
2018-08-09 08:26:21 -07:00
|
|
|
fn bench_sigverify(bencher: &mut Bencher) {
|
2018-08-01 14:10:39 -07:00
|
|
|
let tx = test_tx();
|
|
|
|
|
|
|
|
// generate packet vector
|
2020-06-08 17:38:14 -07:00
|
|
|
let batches = to_packets(&std::iter::repeat(tx).take(128).collect::<Vec<_>>());
|
2018-08-01 14:10:39 -07:00
|
|
|
|
2019-06-27 00:32:32 -07:00
|
|
|
let recycler = Recycler::default();
|
|
|
|
let recycler_out = Recycler::default();
|
2018-08-01 14:10:39 -07:00
|
|
|
// verify packets
|
|
|
|
bencher.iter(|| {
|
2019-06-27 00:32:32 -07:00
|
|
|
let _ans = sigverify::ed25519_verify(&batches, &recycler, &recycler_out);
|
2018-08-01 14:10:39 -07:00
|
|
|
})
|
|
|
|
}
|
2019-10-18 17:52:59 -07:00
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_get_offsets(bencher: &mut Bencher) {
|
|
|
|
let tx = test_tx();
|
|
|
|
|
|
|
|
// generate packet vector
|
2020-06-08 17:38:14 -07:00
|
|
|
let batches = to_packets(&std::iter::repeat(tx).take(1024).collect::<Vec<_>>());
|
2019-10-18 17:52:59 -07:00
|
|
|
|
|
|
|
let recycler = Recycler::default();
|
|
|
|
// verify packets
|
|
|
|
bencher.iter(|| {
|
|
|
|
let ans = sigverify::generate_offsets(&batches, &recycler);
|
|
|
|
assert!(ans.is_ok());
|
2019-12-16 17:11:18 -08:00
|
|
|
let _ans = ans.unwrap();
|
2019-10-18 17:52:59 -07:00
|
|
|
})
|
|
|
|
}
|