Skip to content

Commit bd6212d

Browse files
Merge branch 'main' into fix/operate-with-affine-point-check
2 parents 5a984fa + e38c6b0 commit bd6212d

6 files changed

Lines changed: 115 additions & 131 deletions

File tree

crates/math/benches/fields/baby_bear.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub fn babybear_ops_benchmarks(c: &mut Criterion) {
7777
let mut group = c.benchmark_group("BabyBear operations using Lambdaworks");
7878

7979
for i in input.clone().into_iter() {
80-
group.bench_with_input(format!("Addition {:?}", &i.len()), &i, |bench, i| {
80+
group.bench_with_input(format!("Addition {:?}", i.len()), &i, |bench, i| {
8181
bench.iter(|| {
8282
for (x, y) in i {
8383
black_box(black_box(x) + black_box(y));
@@ -87,7 +87,7 @@ pub fn babybear_ops_benchmarks(c: &mut Criterion) {
8787
}
8888

8989
for i in input.clone().into_iter() {
90-
group.bench_with_input(format!("Multiplication {:?}", &i.len()), &i, |bench, i| {
90+
group.bench_with_input(format!("Multiplication {:?}", i.len()), &i, |bench, i| {
9191
bench.iter(|| {
9292
for (x, y) in i {
9393
black_box(black_box(x) * black_box(y));
@@ -97,7 +97,7 @@ pub fn babybear_ops_benchmarks(c: &mut Criterion) {
9797
}
9898

9999
for i in input.clone().into_iter() {
100-
group.bench_with_input(format!("Square {:?}", &i.len()), &i, |bench, i| {
100+
group.bench_with_input(format!("Square {:?}", i.len()), &i, |bench, i| {
101101
bench.iter(|| {
102102
for (x, _) in i {
103103
black_box(black_box(x).square());
@@ -107,7 +107,7 @@ pub fn babybear_ops_benchmarks(c: &mut Criterion) {
107107
}
108108

109109
for i in input.clone().into_iter() {
110-
group.bench_with_input(format!("Inverse {:?}", &i.len()), &i, |bench, i| {
110+
group.bench_with_input(format!("Inverse {:?}", i.len()), &i, |bench, i| {
111111
bench.iter(|| {
112112
for (x, _) in i {
113113
black_box(black_box(x).inv().unwrap());
@@ -117,7 +117,7 @@ pub fn babybear_ops_benchmarks(c: &mut Criterion) {
117117
}
118118

119119
for i in input.clone().into_iter() {
120-
group.bench_with_input(format!("Division {:?}", &i.len()), &i, |bench, i| {
120+
group.bench_with_input(format!("Division {:?}", i.len()), &i, |bench, i| {
121121
bench.iter(|| {
122122
for (x, y) in i {
123123
black_box(black_box(x) / black_box(y)).unwrap();
@@ -136,7 +136,7 @@ pub fn babybear_extension_ops_benchmarks(c: &mut Criterion) {
136136
let mut group = c.benchmark_group("BabyBear Fp4 operations using Lambdaworks");
137137

138138
for i in input.clone().into_iter() {
139-
group.bench_with_input(format!("Addition of Fp4 {:?}", &i.len()), &i, |bench, i| {
139+
group.bench_with_input(format!("Addition of Fp4 {:?}", i.len()), &i, |bench, i| {
140140
bench.iter(|| {
141141
for (x, y) in i {
142142
black_box(black_box(x) + black_box(y));
@@ -147,7 +147,7 @@ pub fn babybear_extension_ops_benchmarks(c: &mut Criterion) {
147147

148148
for i in input.clone().into_iter() {
149149
group.bench_with_input(
150-
format!("Multiplication of Fp4 {:?}", &i.len()),
150+
format!("Multiplication of Fp4 {:?}", i.len()),
151151
&i,
152152
|bench, i| {
153153
bench.iter(|| {
@@ -160,7 +160,7 @@ pub fn babybear_extension_ops_benchmarks(c: &mut Criterion) {
160160
}
161161

162162
for i in input.clone().into_iter() {
163-
group.bench_with_input(format!("Square of Fp4 {:?}", &i.len()), &i, |bench, i| {
163+
group.bench_with_input(format!("Square of Fp4 {:?}", i.len()), &i, |bench, i| {
164164
bench.iter(|| {
165165
for (x, _) in i {
166166
black_box(black_box(x).square());
@@ -170,7 +170,7 @@ pub fn babybear_extension_ops_benchmarks(c: &mut Criterion) {
170170
}
171171

172172
for i in input.clone().into_iter() {
173-
group.bench_with_input(format!("Inverse of Fp4 {:?}", &i.len()), &i, |bench, i| {
173+
group.bench_with_input(format!("Inverse of Fp4 {:?}", i.len()), &i, |bench, i| {
174174
bench.iter(|| {
175175
for (x, y) in i {
176176
black_box(black_box(x) / black_box(y)).unwrap();
@@ -180,7 +180,7 @@ pub fn babybear_extension_ops_benchmarks(c: &mut Criterion) {
180180
}
181181

182182
for i in input.clone().into_iter() {
183-
group.bench_with_input(format!("Division of Fp4 {:?}", &i.len()), &i, |bench, i| {
183+
group.bench_with_input(format!("Division of Fp4 {:?}", i.len()), &i, |bench, i| {
184184
bench.iter(|| {
185185
for (x, _) in i {
186186
black_box(black_box(x).inv().unwrap());
@@ -199,7 +199,7 @@ pub fn babybear_p3_ops_benchmarks(c: &mut Criterion) {
199199
let mut group = c.benchmark_group("BabyBear operations using Plonky3");
200200

201201
for i in input.clone().into_iter() {
202-
group.bench_with_input(format!("Addition {:?}", &i.len()), &i, |bench, i| {
202+
group.bench_with_input(format!("Addition {:?}", i.len()), &i, |bench, i| {
203203
bench.iter(|| {
204204
for (x, y) in i {
205205
let _ = black_box(black_box(*x) + black_box(*y));
@@ -209,7 +209,7 @@ pub fn babybear_p3_ops_benchmarks(c: &mut Criterion) {
209209
}
210210

211211
for i in input.clone().into_iter() {
212-
group.bench_with_input(format!("Multiplication {:?}", &i.len()), &i, |bench, i| {
212+
group.bench_with_input(format!("Multiplication {:?}", i.len()), &i, |bench, i| {
213213
bench.iter(|| {
214214
for (x, y) in i {
215215
let _ = black_box(black_box(*x) * black_box(*y));
@@ -219,7 +219,7 @@ pub fn babybear_p3_ops_benchmarks(c: &mut Criterion) {
219219
}
220220

221221
for i in input.clone().into_iter() {
222-
group.bench_with_input(format!("Square {:?}", &i.len()), &i, |bench, i| {
222+
group.bench_with_input(format!("Square {:?}", i.len()), &i, |bench, i| {
223223
bench.iter(|| {
224224
for (x, _) in i {
225225
let _ = black_box(black_box(x).square());
@@ -228,7 +228,7 @@ pub fn babybear_p3_ops_benchmarks(c: &mut Criterion) {
228228
});
229229
}
230230
for i in input.clone().into_iter() {
231-
group.bench_with_input(format!("Inverse {:?}", &i.len()), &i, |bench, i| {
231+
group.bench_with_input(format!("Inverse {:?}", i.len()), &i, |bench, i| {
232232
bench.iter(|| {
233233
for (x, _) in i {
234234
let _ = black_box(black_box(x).inverse());
@@ -238,7 +238,7 @@ pub fn babybear_p3_ops_benchmarks(c: &mut Criterion) {
238238
}
239239

240240
for i in input.clone().into_iter() {
241-
group.bench_with_input(format!("Division {:?}", &i.len()), &i, |bench, i| {
241+
group.bench_with_input(format!("Division {:?}", i.len()), &i, |bench, i| {
242242
bench.iter(|| {
243243
for (x, y) in i {
244244
let _ = black_box(black_box(*x) / black_box(*y));
@@ -258,7 +258,7 @@ pub fn babybear_extension_ops_benchmarks_p3(c: &mut Criterion) {
258258
let mut group = c.benchmark_group("BabyBear Fp4 operations using Plonky3");
259259

260260
for i in input.clone().into_iter() {
261-
group.bench_with_input(format!("Addition of Fp4 {:?}", &i.len()), &i, |bench, i| {
261+
group.bench_with_input(format!("Addition of Fp4 {:?}", i.len()), &i, |bench, i| {
262262
bench.iter(|| {
263263
for (x, y) in i {
264264
let _ = black_box(black_box(*x) + black_box(*y));
@@ -268,7 +268,7 @@ pub fn babybear_extension_ops_benchmarks_p3(c: &mut Criterion) {
268268
}
269269
for i in input.clone().into_iter() {
270270
group.bench_with_input(
271-
format!("Multiplication of Fp4 {:?}", &i.len()),
271+
format!("Multiplication of Fp4 {:?}", i.len()),
272272
&i,
273273
|bench, i| {
274274
bench.iter(|| {
@@ -280,7 +280,7 @@ pub fn babybear_extension_ops_benchmarks_p3(c: &mut Criterion) {
280280
);
281281
}
282282
for i in input.clone().into_iter() {
283-
group.bench_with_input(format!("Square of Fp4 {:?}", &i.len()), &i, |bench, i| {
283+
group.bench_with_input(format!("Square of Fp4 {:?}", i.len()), &i, |bench, i| {
284284
bench.iter(|| {
285285
for (x, _) in i {
286286
let _ = black_box(black_box(x).square());
@@ -290,7 +290,7 @@ pub fn babybear_extension_ops_benchmarks_p3(c: &mut Criterion) {
290290
}
291291

292292
for i in input.clone().into_iter() {
293-
group.bench_with_input(format!("Inverse of Fp4 {:?}", &i.len()), &i, |bench, i| {
293+
group.bench_with_input(format!("Inverse of Fp4 {:?}", i.len()), &i, |bench, i| {
294294
bench.iter(|| {
295295
for (x, _) in i {
296296
let _ = black_box(black_box(x).inverse());
@@ -300,7 +300,7 @@ pub fn babybear_extension_ops_benchmarks_p3(c: &mut Criterion) {
300300
}
301301

302302
for i in input.clone().into_iter() {
303-
group.bench_with_input(format!("Division of Fp4 {:?}", &i.len()), &i, |bench, i| {
303+
group.bench_with_input(format!("Division of Fp4 {:?}", i.len()), &i, |bench, i| {
304304
bench.iter(|| {
305305
for (x, y) in i {
306306
let _ = black_box(black_box(*x) / black_box(*y));

crates/math/benches/fields/mersenne31.rs

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn mersenne31_extension_ops_benchmarks(c: &mut Criterion) {
4848
let mut group = c.benchmark_group("Mersenne31 Fp4 operations");
4949

5050
for i in input.clone().into_iter() {
51-
group.bench_with_input(format!("Mul of Fp4 {:?}", &i.len()), &i, |bench, i| {
51+
group.bench_with_input(format!("Mul of Fp4 {:?}", i.len()), &i, |bench, i| {
5252
bench.iter(|| {
5353
for (x, y) in i {
5454
black_box(black_box(x) * black_box(y));
@@ -58,7 +58,7 @@ pub fn mersenne31_extension_ops_benchmarks(c: &mut Criterion) {
5858
}
5959

6060
for i in input.clone().into_iter() {
61-
group.bench_with_input(format!("Square of Fp4 {:?}", &i.len()), &i, |bench, i| {
61+
group.bench_with_input(format!("Square of Fp4 {:?}", i.len()), &i, |bench, i| {
6262
bench.iter(|| {
6363
for (x, _) in i {
6464
black_box(black_box(x).square());
@@ -68,7 +68,7 @@ pub fn mersenne31_extension_ops_benchmarks(c: &mut Criterion) {
6868
}
6969

7070
for i in input.clone().into_iter() {
71-
group.bench_with_input(format!("Inv of Fp4 {:?}", &i.len()), &i, |bench, i| {
71+
group.bench_with_input(format!("Inv of Fp4 {:?}", i.len()), &i, |bench, i| {
7272
bench.iter(|| {
7373
for (x, _) in i {
7474
black_box(black_box(x).inv().unwrap());
@@ -86,7 +86,7 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
8686
let mut group = c.benchmark_group("Mersenne31 operations");
8787

8888
for i in input.clone().into_iter() {
89-
group.bench_with_input(format!("add {:?}", &i.len()), &i, |bench, i| {
89+
group.bench_with_input(format!("add {:?}", i.len()), &i, |bench, i| {
9090
bench.iter(|| {
9191
for (x, y) in i {
9292
black_box(black_box(x) + black_box(y));
@@ -96,7 +96,7 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
9696
}
9797

9898
for i in input.clone().into_iter() {
99-
group.bench_with_input(format!("mul {:?}", &i.len()), &i, |bench, i| {
99+
group.bench_with_input(format!("mul {:?}", i.len()), &i, |bench, i| {
100100
bench.iter(|| {
101101
for (x, y) in i {
102102
black_box(black_box(x) * black_box(y));
@@ -106,7 +106,7 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
106106
}
107107

108108
for i in input.clone().into_iter() {
109-
group.bench_with_input(format!("pow by 1 {:?}", &i.len()), &i, |bench, i| {
109+
group.bench_with_input(format!("pow by 1 {:?}", i.len()), &i, |bench, i| {
110110
bench.iter(|| {
111111
for (x, _) in i {
112112
black_box(black_box(x).pow(1_u64));
@@ -116,7 +116,7 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
116116
}
117117

118118
for i in input.clone().into_iter() {
119-
group.bench_with_input(format!("square {:?}", &i.len()), &i, |bench, i| {
119+
group.bench_with_input(format!("square {:?}", i.len()), &i, |bench, i| {
120120
bench.iter(|| {
121121
for (x, _) in i {
122122
black_box(black_box(x).square());
@@ -126,7 +126,7 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
126126
}
127127

128128
for i in input.clone().into_iter() {
129-
group.bench_with_input(format!("square with pow {:?}", &i.len()), &i, |bench, i| {
129+
group.bench_with_input(format!("square with pow {:?}", i.len()), &i, |bench, i| {
130130
bench.iter(|| {
131131
for (x, _) in i {
132132
black_box(black_box(x).pow(2_u64));
@@ -136,7 +136,7 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
136136
}
137137

138138
for i in input.clone().into_iter() {
139-
group.bench_with_input(format!("square with mul {:?}", &i.len()), &i, |bench, i| {
139+
group.bench_with_input(format!("square with mul {:?}", i.len()), &i, |bench, i| {
140140
bench.iter(|| {
141141
for (x, _) in i {
142142
black_box(black_box(x) * black_box(x));
@@ -146,21 +146,17 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
146146
}
147147

148148
for i in input.clone().into_iter() {
149-
group.bench_with_input(
150-
format!("pow {:?}", &i.len()),
151-
&(i, 5u64),
152-
|bench, (i, a)| {
153-
bench.iter(|| {
154-
for (x, _) in i {
155-
black_box(black_box(x).pow(*a));
156-
}
157-
});
158-
},
159-
);
149+
group.bench_with_input(format!("pow {:?}", i.len()), &(i, 5u64), |bench, (i, a)| {
150+
bench.iter(|| {
151+
for (x, _) in i {
152+
black_box(black_box(x).pow(*a));
153+
}
154+
});
155+
});
160156
}
161157

162158
for i in input.clone().into_iter() {
163-
group.bench_with_input(format!("sub {:?}", &i.len()), &i, |bench, i| {
159+
group.bench_with_input(format!("sub {:?}", i.len()), &i, |bench, i| {
164160
bench.iter(|| {
165161
for (x, y) in i {
166162
black_box(black_box(x) - black_box(y));
@@ -170,7 +166,7 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
170166
}
171167

172168
for i in input.clone().into_iter() {
173-
group.bench_with_input(format!("inv {:?}", &i.len()), &i, |bench, i| {
169+
group.bench_with_input(format!("inv {:?}", i.len()), &i, |bench, i| {
174170
bench.iter(|| {
175171
for (x, _) in i {
176172
black_box(black_box(x).inv().unwrap());
@@ -180,7 +176,7 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
180176
}
181177

182178
for i in input.clone().into_iter() {
183-
group.bench_with_input(format!("div {:?}", &i.len()), &i, |bench, i| {
179+
group.bench_with_input(format!("div {:?}", i.len()), &i, |bench, i| {
184180
bench.iter(|| {
185181
for (x, y) in i {
186182
black_box(black_box(x) / black_box(y)).unwrap();
@@ -190,7 +186,7 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
190186
}
191187

192188
for i in input.clone().into_iter() {
193-
group.bench_with_input(format!("eq {:?}", &i.len()), &i, |bench, i| {
189+
group.bench_with_input(format!("eq {:?}", i.len()), &i, |bench, i| {
194190
bench.iter(|| {
195191
for (x, y) in i {
196192
black_box(black_box(x) == black_box(y));
@@ -200,7 +196,7 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
200196
}
201197

202198
for i in input.clone().into_iter() {
203-
group.bench_with_input(format!("sqrt {:?}", &i.len()), &i, |bench, i| {
199+
group.bench_with_input(format!("sqrt {:?}", i.len()), &i, |bench, i| {
204200
bench.iter(|| {
205201
for (x, _) in i {
206202
black_box(black_box(x).sqrt());
@@ -210,7 +206,7 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
210206
}
211207

212208
for i in input.clone().into_iter() {
213-
group.bench_with_input(format!("sqrt squared {:?}", &i.len()), &i, |bench, i| {
209+
group.bench_with_input(format!("sqrt squared {:?}", i.len()), &i, |bench, i| {
214210
let i: Vec<F> = i.iter().map(|(x, _)| x * x).collect();
215211
bench.iter(|| {
216212
for x in &i {
@@ -221,7 +217,7 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
221217
}
222218

223219
for i in input.clone().into_iter() {
224-
group.bench_with_input(format!("bitand {:?}", &i.len()), &i, |bench, i| {
220+
group.bench_with_input(format!("bitand {:?}", i.len()), &i, |bench, i| {
225221
// Note: we should strive to have the number of limbs be generic... ideally this benchmark group itself should have a generic type that we call into from the main runner.
226222
let i: Vec<(u32, u32)> = i.iter().map(|(x, y)| (*x.value(), *y.value())).collect();
227223
bench.iter(|| {
@@ -233,7 +229,7 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
233229
}
234230

235231
for i in input.clone().into_iter() {
236-
group.bench_with_input(format!("bitor {:?}", &i.len()), &i, |bench, i| {
232+
group.bench_with_input(format!("bitor {:?}", i.len()), &i, |bench, i| {
237233
let i: Vec<(u32, u32)> = i.iter().map(|(x, y)| (*x.value(), *y.value())).collect();
238234
bench.iter(|| {
239235
for (x, y) in &i {
@@ -244,7 +240,7 @@ pub fn mersenne31_ops_benchmarks(c: &mut Criterion) {
244240
}
245241

246242
for i in input.clone().into_iter() {
247-
group.bench_with_input(format!("bitxor {:?}", &i.len()), &i, |bench, i| {
243+
group.bench_with_input(format!("bitxor {:?}", i.len()), &i, |bench, i| {
248244
let i: Vec<(u32, u32)> = i.iter().map(|(x, y)| (*x.value(), *y.value())).collect();
249245
bench.iter(|| {
250246
for (x, y) in &i {

0 commit comments

Comments
 (0)