Permalink
Browse files

Removed benchmarks of mod `basic` due to visibility.

  • Loading branch information...
Messjer committed Aug 18, 2018
1 parent f5ff4a0 commit 5b4f4042756006d4c17a9cee4bbf22f49d19d830
Showing with 0 additions and 76 deletions.
  1. +0 −76 benches/yogcrypt_benchmarks.rs
@@ -4,7 +4,6 @@ extern crate criterion;
extern crate yogcrypt;

use criterion::Criterion;
use yogcrypt::basic::cell::u64x4::*;

mod sm2_benches {
use super::*;
@@ -101,83 +100,8 @@ mod sm4_benches {

}

mod ecc_group_benches {
use super::*;
use yogcrypt::basic::group::ecc_group::*;

fn bench_times(c: &mut Criterion) {
c.bench_function("ecc_group::times_point", move |b| {
b.iter_with_setup(
|| U64x4::random(),
|r| {
times_point(ECC_G, r);
},
)
});
}

fn bench_times_base(c: &mut Criterion) {
c.bench_function("ecc_group::times_base_point", move |b| {
b.iter_with_setup(
|| U64x4::random(),
|r| {
times_base_point(r);
},
)
});
}
criterion_group!(
benches,
ecc_group_benches::bench_times,
ecc_group_benches::bench_times_base
);
}

mod field_p_benches {
use super::*;
use yogcrypt::basic::field::field_p::*;

fn bench_mul(c: &mut Criterion) {
c.bench_function("field_p::mul", move |b| {
b.iter_with_setup(
|| (FieldElement::random(), FieldElement::random()),
|(a, b)| a * b,
)
});
}

fn bench_inversion(c: &mut Criterion) {
c.bench_function("field_p::inv", move |b| {
b.iter_with_setup(
|| FieldElement::random(),
|a| {
get_mul_inv(a);
},
)
});
}

fn bench_add(c: &mut Criterion) {
c.bench_function("field_p:add", move |b| {
b.iter_with_setup(
|| (FieldElement::random(), FieldElement::random()),
|(a, b)| a + b,
)
});
}

criterion_group!(
benches,
field_p_benches::bench_mul,
field_p_benches::bench_inversion,
field_p_benches::bench_add
);
}

criterion_main!(
sm2_benches::benches,
sm3_benches::benches,
sm4_benches::benches,
ecc_group_benches::benches,
field_p_benches::benches
);

3 comments on commit 5b4f404

@mssun

This comment has been minimized.

Copy link
Member

mssun replied Aug 19, 2018

Can we use pub(crate) to preserve the visibility of structs and functions so that we can still do benchmarks? Or do you think it's unnecessary to bench this basic utilities?

@Messjer

This comment has been minimized.

Copy link
Collaborator Author

Messjer replied Aug 20, 2018

Does putting pub(crate) let benchmarks access these functions? I tried it on my machine but it did not work because benchmarks.rs is using yogcrypt as an external library.

Benchmarking these utilities can be helpful to some extent IMO, but is not very necessary.

@mssun

This comment has been minimized.

Copy link
Member

mssun replied Aug 20, 2018

I see, you are correct. Can we move these benchmarks to corresponding files? The yogcrypt_benchmarks.rs file is like integration test, i.e., macro benchmarks. Others like unit tests which are micro benchmarks.

Please sign in to comment.