Merge pull request #205 from elichai/2020-03-bench
Fix broken benchmarks
This commit is contained in:
commit
3fd089712c
|
@ -22,7 +22,7 @@ name = "secp256k1"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
unstable = []
|
unstable = ["recovery", "rand-std"]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = ["secp256k1-sys/std"]
|
std = ["secp256k1-sys/std"]
|
||||||
rand-std = ["rand/std"]
|
rand-std = ["rand/std"]
|
||||||
|
|
|
@ -52,10 +52,10 @@ use core::fmt::{self, write, Write};
|
||||||
use core::intrinsics;
|
use core::intrinsics;
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
|
use secp256k1::ecdh::SharedSecret;
|
||||||
use secp256k1::rand::{self, RngCore};
|
use secp256k1::rand::{self, RngCore};
|
||||||
use secp256k1::serde::Serialize;
|
use secp256k1::serde::Serialize;
|
||||||
use secp256k1::*;
|
use secp256k1::*;
|
||||||
use secp256k1::ecdh::SharedSecret;
|
|
||||||
|
|
||||||
use serde_cbor::de;
|
use serde_cbor::de;
|
||||||
use serde_cbor::ser::SliceWrite;
|
use serde_cbor::ser::SliceWrite;
|
||||||
|
@ -112,23 +112,10 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||||
assert_ne!(x_arr, [0u8; 32]);
|
assert_ne!(x_arr, [0u8; 32]);
|
||||||
assert_ne!(&y_arr[..], &[0u8; 32][..]);
|
assert_ne!(&y_arr[..], &[0u8; 32][..]);
|
||||||
|
|
||||||
|
|
||||||
unsafe { libc::printf("Verified Successfully!\n\0".as_ptr() as _) };
|
unsafe { libc::printf("Verified Successfully!\n\0".as_ptr() as _) };
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
// These functions are used by the compiler, but not
|
|
||||||
// for a bare-bones hello world. These are normally
|
|
||||||
// provided by libstd.
|
|
||||||
#[lang = "eh_personality"]
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn rust_eh_personality() {}
|
|
||||||
|
|
||||||
// This function may be needed based on the compilation target.
|
|
||||||
#[lang = "eh_unwind_resume"]
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn rust_eh_unwind_resume() {}
|
|
||||||
|
|
||||||
const MAX_PRINT: usize = 511;
|
const MAX_PRINT: usize = 511;
|
||||||
struct Print {
|
struct Print {
|
||||||
loc: usize,
|
loc: usize,
|
||||||
|
|
|
@ -304,7 +304,6 @@ mod benches {
|
||||||
let s = Secp256k1::signing_only();
|
let s = Secp256k1::signing_only();
|
||||||
let (sk, pk) = s.generate_keypair(&mut thread_rng());
|
let (sk, pk) = s.generate_keypair(&mut thread_rng());
|
||||||
|
|
||||||
let s = Secp256k1::new();
|
|
||||||
bh.iter( || {
|
bh.iter( || {
|
||||||
let res = SharedSecret::new(&pk, &sk);
|
let res = SharedSecret::new(&pk, &sk);
|
||||||
black_box(res);
|
black_box(res);
|
||||||
|
|
|
@ -363,6 +363,10 @@ mod tests {
|
||||||
|
|
||||||
#[cfg(all(test, feature = "unstable"))]
|
#[cfg(all(test, feature = "unstable"))]
|
||||||
mod benches {
|
mod benches {
|
||||||
|
use rand::{thread_rng, RngCore};
|
||||||
|
use test::{Bencher, black_box};
|
||||||
|
use super::{Message, Secp256k1};
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
pub fn bench_recover(bh: &mut Bencher) {
|
pub fn bench_recover(bh: &mut Bencher) {
|
||||||
let s = Secp256k1::new();
|
let s = Secp256k1::new();
|
||||||
|
|
Loading…
Reference in New Issue