ark_algebra_bench_templates/macros/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#[macro_use]
mod ec;

#[macro_use]
mod field;

#[macro_use]
mod pairing;

#[macro_export]
macro_rules! bench {
    (
        Name = $name:expr,
        Pairing = $Pairing:ident,
        G1 = $G1:ident,
        G2 = $G2:ident,
        ScalarField = $Fr:ident,
        G1BaseField = $Fq:ident,
        G2BaseField = $FqExt:ident,
        TargetField = $FqTarget:ident,
    ) => {
        $crate::ec_bench!($name, $G1);
        $crate::ec_bench!($name, $G2);
        $crate::f_bench!(prime, $name, $Fr);
        $crate::f_bench!(prime, $name, $Fq);
        $crate::f_bench!(extension, $name, $FqExt);
        $crate::f_bench!(target, $name, $FqTarget);
        $crate::pairing_bench!($Pairing);

        paste! {
            criterion_main!(
                [<$G1:lower>]::benches,
                [<$G2:lower>]::benches,
                [<$Fr:lower>]::benches,
                [<$Fq:lower>]::benches,
                [<$FqExt:lower>]::benches,
                [<$FqTarget:lower>]::benches,
                pairing::benches
            );
        }
    };
    (
        Name = $name:expr,
        Group = $G:ident,
        ScalarField = $Fr:ident,
        BaseField = $Fq:ident,
    ) => {
        $crate::ec_bench!($name, $G);
        $crate::f_bench!(prime, $name, $Fr);
        $crate::f_bench!(extension, $name, $Fq);

        paste! {
            criterion_main!(
                [<$G:lower>]::benches,
                [<$Fr:lower>]::benches,
                [<$Fq:lower>]::benches,
            );
        }
    };
    (
        Name = $name:expr,
        Group = $G:ident,
        ScalarField = $Fr:ident,
        PrimeBaseField = $Fq:ident,
    ) => {
        $crate::ec_bench!($name, $G);
        $crate::f_bench!(prime, $name, $Fr);
        $crate::f_bench!(prime, $name, $Fq);

        paste! {
            criterion_main!(
                [<$G:lower>]::benches,
                [<$Fr:lower>]::benches,
                [<$Fq:lower>]::benches,
            );
        }
    };
}