From ac0dcc7ae908f94dcd135e7465f76cf98f30435b Mon Sep 17 00:00:00 2001 From: Pratyush Mishra Date: Thu, 10 Dec 2020 18:22:16 -0800 Subject: [PATCH] Work --- curve-benches/src/macros/ec.rs | 2 +- curve-benches/src/macros/field.rs | 6 +++--- curve-benches/src/macros/pairing.rs | 2 +- curve-benches/src/macros/utils.rs | 26 ++++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/curve-benches/src/macros/ec.rs b/curve-benches/src/macros/ec.rs index 12aa4e5..158fb83 100644 --- a/curve-benches/src/macros/ec.rs +++ b/curve-benches/src/macros/ec.rs @@ -186,7 +186,7 @@ macro_rules! ec_bench { }); } - $crate::bencher::benchmark_group!( + $crate::benchmark_group!( group_ops, rand, mul_assign, diff --git a/curve-benches/src/macros/field.rs b/curve-benches/src/macros/field.rs index 6b662b1..605f7b5 100644 --- a/curve-benches/src/macros/field.rs +++ b/curve-benches/src/macros/field.rs @@ -8,7 +8,7 @@ macro_rules! f_bench { field_common!($f, $f_type); sqrt!($f, $f_type); prime_field!($f, $f_type, $f_repr, $f_repr_type); - $crate::bencher::benchmark_group!( + $crate::benchmark_group!( $modname, // common stuff add_assign, @@ -44,7 +44,7 @@ macro_rules! f_bench { use super::*; field_common!($f, $f_type); sqrt!($f, $f_type); - $crate::bencher::benchmark_group!( + $crate::benchmark_group!( $modname, // common stuff add_assign, @@ -71,7 +71,7 @@ macro_rules! f_bench { mod [<_ $modname>] { use super::*; field_common!($f, $f_type); - $crate::bencher::benchmark_group!( + $crate::benchmark_group!( $modname, // common stuff add_assign, diff --git a/curve-benches/src/macros/pairing.rs b/curve-benches/src/macros/pairing.rs index f932dac..b1f6c12 100644 --- a/curve-benches/src/macros/pairing.rs +++ b/curve-benches/src/macros/pairing.rs @@ -65,7 +65,7 @@ macro_rules! pairing_bench { }); } - $crate::bencher::benchmark_group!( + $crate::benchmark_group!( pairing, miller_loop, final_exponentiation, diff --git a/curve-benches/src/macros/utils.rs b/curve-benches/src/macros/utils.rs index 0caf7d4..2968bca 100644 --- a/curve-benches/src/macros/utils.rs +++ b/curve-benches/src/macros/utils.rs @@ -8,3 +8,29 @@ macro_rules! n_fold { $tmp.$func(); }; } + +/// Defines a function called `$group_name` that returns the test description +/// values for the listed functions `$function`. +#[macro_export] +macro_rules! benchmark_group { + ($group_name:ident, $($function:path),+) => { + pub fn $group_name() -> ::std::vec::Vec<$crate::TestDescAndFn> { + use $crate::{TestDescAndFn, TestFn, TestDesc}; + use std::borrow::Cow; + let mut benches = ::std::vec::Vec::new(); + $( + benches.push(TestDescAndFn { + desc: TestDesc { + name: Cow::from(module_path!().to_string() + "::" + stringify!($function)), + ignore: false, + }, + testfn: TestFn::StaticBenchFn($function), + }); + )+ + benches + } + }; + ($group_name:ident, $($function:path,)+) => { + benchmark_group!($group_name, $($function),+); + }; +}