Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit ea60a52

Browse files
committed
benchmarks
1 parent ba528fc commit ea60a52

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

ethcore/benches/evm.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
2+
// This file is part of Parity.
3+
4+
// Parity is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// Parity is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
16+
17+
#![feature(test)]
18+
19+
extern crate test;
20+
extern crate ethcore_util as util;
21+
extern crate rand;
22+
extern crate bn;
23+
24+
use self::test::{Bencher};
25+
use rand::{StdRng};
26+
27+
28+
#[bench]
29+
fn bn_128_pairing(b: &mut Bencher) {
30+
use bn::{pairing, G1, G2, Fr, Group};
31+
32+
let rng = &mut ::rand::thread_rng();
33+
34+
let sk0 = Fr::random(rng);
35+
let sk1 = Fr::random(rng);
36+
37+
let pk0 = G1::one() * sk0;
38+
let pk1 = G2::one() * sk1;
39+
40+
b.iter(|| {
41+
let _ = pairing(pk0, pk1);
42+
});
43+
}
44+
45+
#[bench]
46+
fn bn_128_mul(b: &mut Bencher) {
47+
use bn::{AffineG1, G1, Fr, Group};
48+
49+
let mut rng = StdRng::new().unwrap();
50+
let p: G1 = G1::random(&mut rng);
51+
let fr = Fr::random(&mut rng);
52+
53+
b.iter(|| {
54+
let _ = AffineG1::from_jacobian(p * fr);
55+
});
56+
}
57+

ethcore/src/builtin.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,7 @@ fn read_point(reader: &mut io::Chain<&[u8], io::Repeat>) -> Result<::bn::G1, Err
346346
let px = Fq::from_slice(&buf[0..32]).map_err(|_| Error::from("Invalid point x coordinate"))?;
347347

348348
reader.read_exact(&mut buf[..]).expect("reading from zero-extended memory cannot fail; qed");
349-
let py = Fq::from_slice(&buf[0..32]).map_err(|_| Error::from("Invalid point x coordinate"))?;
350-
349+
let py = Fq::from_slice(&buf[0..32]).map_err(|_| Error::from("Invalid point y coordinate"))?;
351350
Ok(
352351
if px == Fq::zero() && py == Fq::zero() {
353352
G1::zero()

0 commit comments

Comments
 (0)