From 62f16201572e41313486046c36c481cd007f4876 Mon Sep 17 00:00:00 2001 From: Ragnar Date: Mon, 22 Sep 2025 01:05:24 +0200 Subject: [PATCH] Update mersenne31.rs --- crates/math/benches/fields/mersenne31.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/math/benches/fields/mersenne31.rs b/crates/math/benches/fields/mersenne31.rs index 0601d5e95..555ff449d 100644 --- a/crates/math/benches/fields/mersenne31.rs +++ b/crates/math/benches/fields/mersenne31.rs @@ -14,20 +14,25 @@ pub type F = FieldElement; pub type Fp2E = FieldElement; pub type Fp4E = FieldElement; +/// Generates random Mersenne31 field elements for benchmarking. +/// This function creates pairs of random field elements using the same pattern +/// as other benchmark functions in the codebase. #[inline(never)] #[export_name = "util::rand_mersenne31_field_elements"] pub fn rand_field_elements(num: usize) -> Vec<(F, F)> { let mut result = Vec::with_capacity(num); - for _ in 0..result.capacity() { + for _ in 0..num { result.push((F::new(random()), F::new(random()))); } result } -//TODO: Check if this is the correct way to bench. +/// Generates random Fp4E field elements for benchmarking. +/// This function creates pairs of random Fp4E elements using the same pattern +/// as other benchmark functions in the codebase. pub fn rand_fp4e(num: usize) -> Vec<(Fp4E, Fp4E)> { let mut result = Vec::with_capacity(num); - for _ in 0..result.capacity() { + for _ in 0..num { result.push(( Fp4E::new([ Fp2E::new([F::new(random()), F::new(random())]),