add sr25519 bench (#4905)

This commit is contained in:
Nikolay Volf
2020-02-12 17:32:38 +03:00
committed by GitHub
parent 35b5cdd29b
commit a84c05da22
3 changed files with 21 additions and 21 deletions
+21 -1
View File
@@ -86,9 +86,29 @@ fn bench_ed25519(c: &mut Criterion) {
}, vec![32, 1024, 1024 * 1024]);
}
fn bench_sr25519(c: &mut Criterion) {
c.bench_function_over_inputs("signing - sr25519", |b, &msg_size| {
let msg = (0..msg_size)
.map(|_| rand::random::<u8>())
.collect::<Vec<_>>();
let key = sp_core::sr25519::Pair::generate().0;
b.iter(|| key.sign(&msg))
}, vec![32, 1024, 1024 * 1024]);
c.bench_function_over_inputs("verifying - sr25519", |b, &msg_size| {
let msg = (0..msg_size)
.map(|_| rand::random::<u8>())
.collect::<Vec<_>>();
let key = sp_core::sr25519::Pair::generate().0;
let sig = key.sign(&msg);
let public = key.public();
b.iter(|| sp_core::sr25519::Pair::verify(&sig, &msg, &public))
}, vec![32, 1024, 1024 * 1024]);
}
criterion_group!{
name = benches;
config = Criterion::default().warm_up_time(Duration::from_millis(500)).without_plots();
targets = bench_hash_128_fix_size, bench_hash_128_dyn_size, bench_ed25519
targets = bench_hash_128_fix_size, bench_hash_128_dyn_size, bench_ed25519, bench_sr25519
}
criterion_main!(benches);
-3
View File
@@ -70,9 +70,6 @@ mod changes_trie;
pub mod traits;
pub mod testing;
#[cfg(test)]
mod tests;
pub use self::hash::{H160, H256, H512, convert_hash};
pub use self::uint::U256;
pub use changes_trie::{ChangesTrieConfiguration, ChangesTrieConfigurationRange};
-17
View File
@@ -1,17 +0,0 @@
// Copyright 2017-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Substrate is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
//! Tests.