@@ -40,6 +40,8 @@ pub struct CheckCtx {
40
40
/// Source of truth for tests.
41
41
pub basis : CheckBasis ,
42
42
pub gen_kind : GeneratorKind ,
43
+ /// If specified, this value will override the value returned by [`iteration_count`].
44
+ pub override_iterations : Option < u64 > ,
43
45
}
44
46
45
47
impl CheckCtx {
@@ -53,6 +55,7 @@ impl CheckCtx {
53
55
base_name_str : fn_ident. base_name ( ) . as_str ( ) ,
54
56
basis,
55
57
gen_kind,
58
+ override_iterations : None ,
56
59
} ;
57
60
ret. ulp = crate :: default_ulp ( & ret) ;
58
61
ret
@@ -62,6 +65,10 @@ impl CheckCtx {
62
65
pub fn input_count ( & self ) -> usize {
63
66
self . fn_ident . math_op ( ) . rust_sig . args . len ( )
64
67
}
68
+
69
+ pub fn override_iterations ( & mut self , count : u64 ) {
70
+ self . override_iterations = Some ( count)
71
+ }
65
72
}
66
73
67
74
/// Possible items to test against
@@ -71,6 +78,8 @@ pub enum CheckBasis {
71
78
Musl ,
72
79
/// Check against infinite precision (MPFR).
73
80
Mpfr ,
81
+ /// Benchmarks or other times when this is not relevant.
82
+ None ,
74
83
}
75
84
76
85
/// The different kinds of generators that provide test input, which account for input pattern
@@ -216,13 +225,20 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
216
225
total_iterations = 800 ;
217
226
}
218
227
228
+ let mut overridden = false ;
229
+ if let Some ( count) = ctx. override_iterations {
230
+ total_iterations = count;
231
+ overridden = true ;
232
+ }
233
+
219
234
// Adjust for the number of inputs
220
235
let ntests = match t_env. input_count {
221
236
1 => total_iterations,
222
237
2 => ( total_iterations as f64 ) . sqrt ( ) . ceil ( ) as u64 ,
223
238
3 => ( total_iterations as f64 ) . cbrt ( ) . ceil ( ) as u64 ,
224
239
_ => panic ! ( "test has more than three arguments" ) ,
225
240
} ;
241
+
226
242
let total = ntests. pow ( t_env. input_count . try_into ( ) . unwrap ( ) ) ;
227
243
228
244
let seed_msg = match ctx. gen_kind {
@@ -235,12 +251,13 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
235
251
236
252
test_log ( & format ! (
237
253
"{gen_kind:?} {basis:?} {fn_ident} arg {arg}/{args}: {ntests} iterations \
238
- ({total} total){seed_msg}",
254
+ ({total} total){seed_msg}{omsg} ",
239
255
gen_kind = ctx. gen_kind,
240
256
basis = ctx. basis,
241
257
fn_ident = ctx. fn_ident,
242
258
arg = argnum + 1 ,
243
259
args = t_env. input_count,
260
+ omsg = if overridden { " (overridden)" } else { "" }
244
261
) ) ;
245
262
246
263
ntests
0 commit comments