Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
fr_straight.bench.cpp
Go to the documentation of this file.
1#include "fr.hpp"
2
3#include <benchmark/benchmark.h>
4
5using namespace bb;
6using namespace benchmark;
7
8#ifndef DISABLE_ASM
9namespace {
10void asm_add_with_coarse_reduction(State& state) noexcept
11{
12 fr x, y;
13 for (auto _ : state) {
14 DoNotOptimize(fr::asm_add_with_coarse_reduction(x, y));
15 }
16}
17BENCHMARK(asm_add_with_coarse_reduction);
18
19void asm_conditional_negate(State& state) noexcept
20{
21 fr x;
22 for (auto _ : state) {
23 fr::asm_conditional_negate(x, true);
24 }
25}
26BENCHMARK(asm_conditional_negate);
27
28void asm_mul_with_coarse_reduction(State& state) noexcept
29{
30 fr x, y;
31 for (auto _ : state) {
32 DoNotOptimize(fr::asm_mul_with_coarse_reduction(x, y));
33 }
34}
35BENCHMARK(asm_mul_with_coarse_reduction);
36
37void asm_reduce_once(State& state) noexcept
38{
39 fr x;
40 for (auto _ : state) {
41 DoNotOptimize(fr::asm_reduce_once(x));
42 }
43}
44BENCHMARK(asm_reduce_once);
45
46void asm_self_add_with_coarse_reduction(State& state) noexcept
47{
48 fr x, y;
49 for (auto _ : state) {
50 fr::asm_self_add_with_coarse_reduction(x, y);
51 }
52}
53BENCHMARK(asm_self_add_with_coarse_reduction);
54
55void asm_self_mul_with_coarse_reduction(State& state) noexcept
56{
57 fr x, y;
58 for (auto _ : state) {
59 fr::asm_self_mul_with_coarse_reduction(x, y);
60 }
61}
62BENCHMARK(asm_self_mul_with_coarse_reduction);
63
64void asm_self_reduce_once(State& state) noexcept
65{
66 fr x;
67 for (auto _ : state) {
68 fr::asm_self_reduce_once(x);
69 }
70}
71BENCHMARK(asm_self_reduce_once);
72
73void asm_self_sqr_with_coarse_reduction(State& state) noexcept
74{
75 fr x;
76 for (auto _ : state) {
77 fr::asm_self_sqr_with_coarse_reduction(x);
78 }
79}
80BENCHMARK(asm_self_sqr_with_coarse_reduction);
81
82void asm_self_sub_with_coarse_reduction(State& state) noexcept
83{
84 fr x, y;
85 for (auto _ : state) {
86 fr::asm_self_sub_with_coarse_reduction(x, y);
87 }
88}
89BENCHMARK(asm_self_sub_with_coarse_reduction);
90
91void asm_sqr_with_coarse_reduction(State& state) noexcept
92{
93 fr x;
94 for (auto _ : state) {
95 DoNotOptimize(fr::asm_sqr_with_coarse_reduction(x));
96 }
97}
98BENCHMARK(asm_sqr_with_coarse_reduction);
99
100void mul(State& state) noexcept
101{
102 fr x, y;
103 for (auto _ : state) {
104 DoNotOptimize(x * y);
105 }
106}
107BENCHMARK(mul);
108
109void self_mul(State& state) noexcept
110{
111 fr x, y;
112 for (auto _ : state) {
113 x *= y;
114 }
115}
116BENCHMARK(self_mul);
117
118void add(State& state) noexcept
119{
120 fr x, y;
121 for (auto _ : state) {
122 DoNotOptimize(x + y);
123 }
124}
125BENCHMARK(add);
126
127void self_add(State& state) noexcept
128{
129 fr x, y;
130 for (auto _ : state) {
131 x += y;
132 }
133}
134BENCHMARK(self_add);
135
136void sub(State& state) noexcept
137{
138 fr x, y;
139 for (auto _ : state) {
140 DoNotOptimize(x - y);
141 }
142}
143BENCHMARK(sub);
144
145void self_sub(State& state) noexcept
146{
147 fr x, y;
148 for (auto _ : state) {
149 x -= y;
150 }
151}
152BENCHMARK(self_sub);
153
154void invert(State& state) noexcept
155{
156 fr x;
157 for (auto _ : state) {
158 DoNotOptimize(x.invert());
159 }
160}
161BENCHMARK(invert);
162
163void self_neg(State& state) noexcept
164{
165 fr x;
166 for (auto _ : state) {
167 x.self_neg();
168 }
169}
170BENCHMARK(self_neg);
171
172void self_reduce_once(State& state) noexcept
173{
174 fr x;
175 for (auto _ : state) {
177 }
178}
179BENCHMARK(self_reduce_once);
180
181void self_to_montgomery_form(State& state) noexcept
182{
183 fr x;
184 for (auto _ : state) {
186 }
187}
188BENCHMARK(self_to_montgomery_form);
189
190void self_sqr(State& state) noexcept
191{
192 fr x;
193 for (auto _ : state) {
194 x.self_sqr();
195 }
196}
197BENCHMARK(self_sqr);
198
199void sqr(State& state) noexcept
200{
201 fr x;
202 for (auto _ : state) {
203 DoNotOptimize(x.sqr());
204 }
205}
206BENCHMARK(sqr);
207} // namespace
208#endif
209
210// NOLINTNEXTLINE macro invocation triggers style guideline errors from googletest code
BENCHMARK_MAIN()
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
BENCHMARK(bench_commit_structured_random_poly< curve::BN254 >) -> Unit(benchmark::kMillisecond)
BB_INLINE constexpr void self_reduce_once() &noexcept
BB_INLINE constexpr void self_sqr() &noexcept
constexpr field invert() const noexcept
BB_INLINE constexpr void self_neg() &noexcept
BB_INLINE constexpr field sqr() const noexcept
BB_INLINE constexpr void self_to_montgomery_form() &noexcept