@@ -56,7 +56,7 @@ fn benchmark_sequential_vs_parallel(c: &mut Criterion) {
5656 . par_iter ( )
5757 . map ( |d| parse ( black_box ( d) ) )
5858 . collect :: < Result < Vec < String > , ParserError > > ( )
59- } )
59+ } ) ;
6060 } ) ;
6161
6262 // Benchmark sequential parsing
@@ -66,7 +66,7 @@ fn benchmark_sequential_vs_parallel(c: &mut Criterion) {
6666 . iter ( )
6767 . map ( |d| parse ( black_box ( d) ) )
6868 . collect :: < Result < Vec < String > , ParserError > > ( )
69- } )
69+ } ) ;
7070 } ) ;
7171
7272 group. finish ( ) ;
@@ -98,7 +98,7 @@ fn benchmark_parallel_efficiency(c: &mut Criterion) {
9898 . par_iter ( )
9999 . map ( |d| parse ( black_box ( d) ) )
100100 . collect :: < Result < Vec < String > , ParserError > > ( )
101- } )
101+ } ) ;
102102 } ) ;
103103 }
104104
@@ -123,7 +123,7 @@ fn benchmark_per_filetype(c: &mut Criterion) {
123123 . par_iter ( )
124124 . map ( |d| parse ( black_box ( d) ) )
125125 . collect :: < Result < Vec < String > , ParserError > > ( )
126- } )
126+ } ) ;
127127 } ) ;
128128 }
129129
@@ -144,7 +144,7 @@ fn benchmark_per_filetype(c: &mut Criterion) {
144144 . par_iter ( )
145145 . map ( |d| parse ( black_box ( d) ) )
146146 . collect :: < Result < Vec < String > , ParserError > > ( )
147- } )
147+ } ) ;
148148 } ) ;
149149 }
150150
@@ -153,6 +153,7 @@ fn benchmark_per_filetype(c: &mut Criterion) {
153153
154154// Finds the threshold number of files for each type that takes less than 16ms
155155fn benchmark_parallel_threshold ( c : & mut Criterion ) {
156+ const SAMPLE_COUNT : usize = 5 ;
156157 let max_time_threshold = Duration :: from_millis ( 16 ) ;
157158
158159 // Read each test file only once
@@ -181,7 +182,6 @@ fn benchmark_parallel_threshold(c: &mut Criterion) {
181182 }
182183
183184 // Take multiple measurements and use median for robustness
184- const SAMPLE_COUNT : usize = 5 ;
185185 let mut durations = Vec :: with_capacity ( SAMPLE_COUNT ) ;
186186
187187 for _ in 0 ..SAMPLE_COUNT {
@@ -227,13 +227,16 @@ fn benchmark_parallel_threshold(c: &mut Criterion) {
227227 // The threshold count is now in 'low'
228228 let threshold_count = low;
229229
230- // Define percentages to test around the threshold
231- let percentages = [ 99.0 , 99.9 , 100.0 , 100.1 , 101.0 ] ;
230+ // Permille values for percentages: 99.0%, 99.9%, 100.0%, 100.1%, 101.0%
231+ let permille_values : [ usize ; 5 ] = [ 990 , 999 , 1000 , 1001 , 1010 ] ;
232232
233- // Generate test points based on percentages of the threshold
234- let mut test_points: Vec < usize > = percentages
233+ // Generate test points based on percentages of the threshold using integer math
234+ let mut test_points: Vec < usize > = permille_values
235235 . iter ( )
236- . map ( |& p| ( ( threshold_count as f64 * p / 100.0 ) . ceil ( ) as usize ) . max ( 1 ) )
236+ . map ( |& p| {
237+ let product = threshold_count. saturating_mul ( p) ;
238+ product. div_ceil ( 1000 ) . max ( 1 )
239+ } )
237240 . collect ( ) ;
238241
239242 test_points. dedup ( ) ;
@@ -251,7 +254,7 @@ fn benchmark_parallel_threshold(c: &mut Criterion) {
251254 . par_iter ( )
252255 . map ( |d| parse ( black_box ( d) ) )
253256 . collect :: < Result < Vec < String > , ParserError > > ( )
254- } )
257+ } ) ;
255258 } ) ;
256259 }
257260
0 commit comments