@@ -144,12 +144,6 @@ def run_bench(
144144 ld_libraries = options .extra_ld_libraries .copy ()
145145 ld_libraries .extend (ld_library )
146146
147- # When tracing, reduce internal iterations of benchmarks to shorten
148- # trace capture time while keeping representative behavior. This
149- # rewrites common iteration flags in the command line.
150- if run_trace != TracingType .NONE :
151- command = self ._reduce_internal_iterations_for_tracing (command )
152-
153147 unitrace_output = None
154148 if (
155149 self .traceable (TracingType .UNITRACE ) or force_trace
@@ -211,84 +205,6 @@ def run_bench(
211205 else :
212206 return result .stderr .decode ()
213207
214- def _reduce_internal_iterations_for_tracing (self , command : list [str ]) -> list [str ]:
215- """Reduce internal benchmark iterations when tracing to avoid long runs.
216-
217- This function scans common iteration/count flags and reduces their
218- values. It is conservative and only applies to known patterns.
219-
220- Handled patterns (with default caps):
221- - --iterations=N -> min(int(N*0.1), 1000)
222- - --count=N -> min(int(N*0.1), 100)
223- - --repetitions=N -> min(int(N*0.1), 50)
224- - --repeat=N -> min(int(N*0.1), 50)
225- - --niter=N -> min(int(N*0.1), 1000)
226-
227- Never goes below 1 and only changes numeric values.
228- """
229- def _scale (value : int , factor : float , cap : int ) -> int :
230- scaled = max (1 , int (value * factor ))
231- return min (scaled , cap )
232-
233- patterns = {
234- "--iterations" : (0.1 , 1000 ),
235- "--count" : (0.1 , 100 ),
236- "--repetitions" : (0.1 , 50 ),
237- "--repeat" : (0.1 , 50 ),
238- "--niter" : (0.1 , 1000 ),
239- }
240-
241- new_cmd : list [str ] = []
242- changes : list [tuple [str , int , int ]] = []
243- i = 0
244- while i < len (command ):
245- tok = command [i ]
246- replaced = False
247- # Handle --flag=value form
248- for flag , (factor , cap ) in patterns .items ():
249- prefix = flag + "="
250- if tok .startswith (prefix ):
251- val_str = tok [len (prefix ) :]
252- if val_str .isdigit ():
253- old = int (val_str )
254- new = _scale (old , factor , cap )
255- if new != old :
256- new_tok = f"{ flag } ={ new } "
257- new_cmd .append (new_tok )
258- changes .append ((flag , old , new ))
259- replaced = True
260- break
261- if replaced :
262- i += 1
263- continue
264-
265- # Handle "--flag <value>" form
266- if tok in patterns and i + 1 < len (command ):
267- val_str = command [i + 1 ]
268- if isinstance (val_str , str ) and val_str .isdigit ():
269- factor , cap = patterns [tok ]
270- old = int (val_str )
271- new = _scale (old , factor , cap )
272- if new != old :
273- new_cmd .append (tok )
274- new_cmd .append (str (new ))
275- changes .append ((tok , old , new ))
276- i += 2
277- continue
278-
279- # default: keep token
280- new_cmd .append (tok )
281- i += 1
282-
283- if changes :
284- for flag , old , new in changes :
285- log .debug (
286- f"Tracing: adjusted internal iterations { flag } : { old } -> { new } "
287- )
288- log .debug ("Tracing: adjusted command: " + " " .join (new_cmd ))
289-
290- return new_cmd
291-
292208 def create_data_path (self , name , skip_data_dir = False ):
293209 if skip_data_dir :
294210 data_path = os .path .join (self .directory , name )
0 commit comments