From 389779d86ca0d714cff0a8861a0f9ac58219d6d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 9 Mar 2016 00:05:47 +0100 Subject: [PATCH] Updating benchmarks to avoid inlining/optimizing --- util/benches/bigint.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/util/benches/bigint.rs b/util/benches/bigint.rs index 80c4ce1d8..3f4164d18 100644 --- a/util/benches/bigint.rs +++ b/util/benches/bigint.rs @@ -50,9 +50,16 @@ fn u256_sub(b: &mut Bencher) { fn u512_sub(b: &mut Bencher) { b.iter(|| { let n = black_box(10000); - (0..n).fold(U512([rand::random::(), rand::random::(), rand::random::(), rand::random::(), - rand::random::(), rand::random::(), rand::random::(), rand::random::()]), - |old, new| { old.overflowing_sub(U512([0, 0, 0, 0, 0, 0, 0, new])).0 }) + (0..n).fold( + U512([ + rand::random::(), rand::random::(), rand::random::(), rand::random::(), + rand::random::(), rand::random::(), rand::random::(), rand::random::() + ]), + |old, new| { + let p = new % 2; + old.overflowing_sub(U512([p, p, p, p, p, p, p, new])).0 + } + ) }); }