mirror of
https://github.com/arnaucube/mimc-rs.git
synced 2026-02-07 03:26:43 +01:00
Add benchmark
On a Intel(R) Core(TM) i7-8705G CPU @ 3.10GHz, with 32 GB of RAM: hash time: [927.61 us 927.78 us 927.98 us]
This commit is contained in:
12
Cargo.toml
12
Cargo.toml
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "mimc-rs"
|
name = "mimc-rs"
|
||||||
version = "0.0.2"
|
version = "0.0.3"
|
||||||
authors = ["arnaucube <root@arnaucube.com>"]
|
authors = ["arnaucube <root@arnaucube.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
@@ -9,8 +9,18 @@ repository = "https://github.com/arnaucube/mimc-rs"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
ff = {package="ff_ce" , version="0.11", features = ["derive"]}
|
||||||
|
rand = "0.4"
|
||||||
|
|
||||||
num = "0.2.0"
|
num = "0.2.0"
|
||||||
num-bigint = "0.2.2"
|
num-bigint = "0.2.2"
|
||||||
num-traits = "0.2.8"
|
num-traits = "0.2.8"
|
||||||
tiny-keccak = "1.5"
|
tiny-keccak = "1.5"
|
||||||
rustc-hex = "1.0.0"
|
rustc-hex = "1.0.0"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
criterion = "0.3"
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "bench_mimc_hash"
|
||||||
|
harness = false
|
||||||
|
|||||||
27
benches/bench_mimc_hash.rs
Normal file
27
benches/bench_mimc_hash.rs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
|
use num_bigint::BigInt;
|
||||||
|
|
||||||
|
use mimc_rs::Mimc7;
|
||||||
|
|
||||||
|
fn criterion_benchmark(c: &mut Criterion) {
|
||||||
|
let b1: BigInt = BigInt::parse_bytes(
|
||||||
|
b"12242166908188651009877250812424843524687801523336557272219921456462821518061",
|
||||||
|
10,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let b2: BigInt = BigInt::parse_bytes(
|
||||||
|
b"12242166908188651009877250812424843524687801523336557272219921456462821518061",
|
||||||
|
10,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let mut big_arr: Vec<BigInt> = Vec::new();
|
||||||
|
big_arr.push(b1.clone());
|
||||||
|
big_arr.push(b2.clone());
|
||||||
|
let mimc7 = Mimc7::new();
|
||||||
|
|
||||||
|
c.bench_function("hash", |b| b.iter(|| mimc7.hash(big_arr.clone()).unwrap()));
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
criterion_main!(benches);
|
||||||
Reference in New Issue
Block a user