ark-curves-cherry-picked/curve-benches/src/macros/utils.rs
curve-benches/src/macros/utils.rsRaw
1#[macro_export]
2macro_rules! n_fold {
3 ($tmp:ident, $v:ident, $func:ident, $count:ident) => {
4 $tmp.$func(&$v[$count].1);
5 };
6
7 ($tmp:ident, $func:ident) => {
8 $tmp.$func();
9 };
10}
11
12/// Defines a function called `$group_name` that returns the test description
13/// values for the listed functions `$function`.
14#[macro_export]
15macro_rules! benchmark_group {
16 ($group_name:ident, $($function:path),+) => {
17 pub fn $group_name() -> ::std::vec::Vec<$crate::TestDescAndFn> {
18 use $crate::{TestDescAndFn, TestFn, TestDesc};
19 use std::borrow::Cow;
20 let mut benches = ::std::vec::Vec::new();
21 $(
22 benches.push(TestDescAndFn {
23 desc: TestDesc {
24 name: Cow::from(module_path!().to_string() + "::" + stringify!($function)),
25 ignore: false,
26 },
27 testfn: TestFn::StaticBenchFn($function),
28 });
29 )+
30 benches
31 }
32 };
33 ($group_name:ident, $($function:path,)+) => {
34 benchmark_group!($group_name, $($function),+);
35 };
36}