Skip to content

Commit 3fd0897

Browse files
authored
Merge pull request #205 from elichai/2020-03-bench
Fix broken benchmarks
2 parents ab59498 + 18259fd commit 3fd0897

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ name = "secp256k1"
2222
path = "src/lib.rs"
2323

2424
[features]
25-
unstable = []
25+
unstable = ["recovery", "rand-std"]
2626
default = ["std"]
2727
std = ["secp256k1-sys/std"]
2828
rand-std = ["rand/std"]

no_std_test/src/main.rs

+7-20
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
//! # secp256k1 no-std test.
1616
//! This binary is a short smallest rust code to produce a working binary *without libstd*.
17-
//! This gives us 2 things:
17+
//! This gives us 2 things:
1818
//! 1. Test that the parts of the code that should work in a no-std enviroment actually work.
1919
//! 2. Test that we don't accidentally import libstd into `secp256k1`.
20-
//!
20+
//!
2121
//! The first is tested using the following command `cargo run --release | grep -q "Verified Successfully"`.
2222
//! (Making sure that it successfully printed that. i.e. it didn't abort before that).
23-
//!
23+
//!
2424
//! The second is tested by the fact that it compiles. if we accidentally link against libstd we should see the following error:
2525
//! `error[E0152]: duplicate lang item found`.
2626
//! Example:
@@ -33,11 +33,11 @@
3333
//! |
3434
//! = note: first defined in crate `panic_unwind` (which `std` depends on).
3535
//! ```
36-
//!
37-
//! Notes:
36+
//!
37+
//! Notes:
3838
//! * Requires `panic=abort` and `--release` to not depend on libunwind(which is provided usually by libstd) https://github.com/rust-lang/rust/issues/47493
3939
//! * Requires linking with `libc` for calling `printf`.
40-
//!
40+
//!
4141
4242
#![feature(lang_items)]
4343
#![feature(start)]
@@ -52,10 +52,10 @@ use core::fmt::{self, write, Write};
5252
use core::intrinsics;
5353
use core::panic::PanicInfo;
5454

55+
use secp256k1::ecdh::SharedSecret;
5556
use secp256k1::rand::{self, RngCore};
5657
use secp256k1::serde::Serialize;
5758
use secp256k1::*;
58-
use secp256k1::ecdh::SharedSecret;
5959

6060
use serde_cbor::de;
6161
use serde_cbor::ser::SliceWrite;
@@ -111,24 +111,11 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
111111
})}.unwrap();
112112
assert_ne!(x_arr, [0u8; 32]);
113113
assert_ne!(&y_arr[..], &[0u8; 32][..]);
114-
115114

116115
unsafe { libc::printf("Verified Successfully!\n\0".as_ptr() as _) };
117116
0
118117
}
119118

120-
// These functions are used by the compiler, but not
121-
// for a bare-bones hello world. These are normally
122-
// provided by libstd.
123-
#[lang = "eh_personality"]
124-
#[no_mangle]
125-
pub extern "C" fn rust_eh_personality() {}
126-
127-
// This function may be needed based on the compilation target.
128-
#[lang = "eh_unwind_resume"]
129-
#[no_mangle]
130-
pub extern "C" fn rust_eh_unwind_resume() {}
131-
132119
const MAX_PRINT: usize = 511;
133120
struct Print {
134121
loc: usize,

src/ecdh.rs

-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ mod benches {
304304
let s = Secp256k1::signing_only();
305305
let (sk, pk) = s.generate_keypair(&mut thread_rng());
306306

307-
let s = Secp256k1::new();
308307
bh.iter( || {
309308
let res = SharedSecret::new(&pk, &sk);
310309
black_box(res);

src/recovery.rs

+4
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ mod tests {
363363

364364
#[cfg(all(test, feature = "unstable"))]
365365
mod benches {
366+
use rand::{thread_rng, RngCore};
367+
use test::{Bencher, black_box};
368+
use super::{Message, Secp256k1};
369+
366370
#[bench]
367371
pub fn bench_recover(bh: &mut Bencher) {
368372
let s = Secp256k1::new();

0 commit comments

Comments
 (0)