@@ -114,12 +114,15 @@ def name_only_note(found) -> str:
114114 is searched, with the first benchmark's parameters, in order, and one case as it is searched."""
115115 first = found [0 ]
116116 names = ", " .join (info ["name" ] for info in found [:3 ])
117- return "\n " .join ([
118- f"the filter matches the name of a parametrized benchmark ({ names } ) but not its arguments." ,
119- "They are searched as name(p0, p1), each as its repr, in the order of param_names:" ,
120- f" { first ['name' ]} ({ ', ' .join (first ['param_names' ])} )" ,
121- "for example:" ,
122- f" { search_name (first ['name' ], first ['params' ], 0 )} " ])
117+ return "\n " .join (
118+ [
119+ f"the filter matches the name of a parametrized benchmark ({ names } ) but not its arguments." ,
120+ "They are searched as name(p0, p1), each as its repr, in the order of param_names:" ,
121+ f" { first ['name' ]} ({ ', ' .join (first ['param_names' ])} )" ,
122+ "for example:" ,
123+ f" { search_name (first ['name' ], first ['params' ], 0 )} " ,
124+ ]
125+ )
123126
124127
125128def similar (case_filter , names , limit = 5 , cutoff = 0.75 ) -> list [str ]:
@@ -178,8 +181,9 @@ def last_json(out: subprocess.CompletedProcess, what: str):
178181 return json .loads (lines [- 1 ])
179182 except (IndexError , ValueError ):
180183 found = f"its last line of output is { lines [- 1 ][:80 ]!r} " if lines else "it printed nothing"
181- raise Unsupported (f"cannot read the benchmark listing of { what } : { found } , not the JSON "
182- "the listing ends with" ) from None
184+ raise Unsupported (
185+ f"cannot read the benchmark listing of { what } : { found } , not the JSON the listing ends with"
186+ ) from None
183187
184188
185189# How long a benchmark's manager gets to tidy up after Ctrl-C before its group is killed. pyperf, given Ctrl-C on its
@@ -207,8 +211,10 @@ def kill_group(proc) -> tuple[str, str]:
207211 for pipe in (proc .stdout , proc .stderr ): # what arrived is in the exception, as bytes
208212 if pipe is not None :
209213 pipe .close ()
210- return tuple (data .decode (errors = "backslashreplace" ) if isinstance (data , bytes ) else data or ""
211- for data in (holding .stdout , holding .stderr ))
214+ return tuple (
215+ data .decode (errors = "backslashreplace" ) if isinstance (data , bytes ) else data or ""
216+ for data in (holding .stdout , holding .stderr )
217+ )
212218
213219
214220def stop_group (proc , grace = STOP_GRACE_S ) -> None :
@@ -231,8 +237,13 @@ def note_cases(adapter_logger, cases, case_filter, limit=40) -> list:
231237 """What `list_cases` found, for the log: how many, under which filter, and the first `limit` names."""
232238 shown = cases [:limit ]
233239 more = f", and { len (cases ) - len (shown )} more" if len (cases ) > len (shown ) else ""
234- adapter_logger .debug ("%d case(s)%s: %s%s" , len (cases ), f" for the filter { case_filter !r} " if case_filter else "" ,
235- ", " .join (shown ), more )
240+ adapter_logger .debug (
241+ "%d case(s)%s: %s%s" ,
242+ len (cases ),
243+ f" for the filter { case_filter !r} " if case_filter else "" ,
244+ ", " .join (shown ),
245+ more ,
246+ )
236247 return cases
237248
238249
@@ -241,10 +252,13 @@ def note_parameters(adapter_logger, runnable, limit=40) -> None:
241252 strings) and the number of combinations, one case each. At most `limit` benchmarks."""
242253 found = [(name , info ) for name , info in runnable .get ("benchmarks" , {}).items () if info .get ("param_names" )]
243254 for name , info in found [:limit ]:
244- values = ", " .join (f"{ parameter } : { ', ' .join (shown [:10 ])} { ', …' if len (shown ) > 10 else '' } "
245- for parameter , shown in zip (info ["param_names" ], info ["params" ]))
246- adapter_logger .debug ("%s: %d combination(s) of %s" , name , math .prod (len (shown ) for shown in info ["params" ]),
247- values )
255+ values = ", " .join (
256+ f"{ parameter } : { ', ' .join (shown [:10 ])} { ', …' if len (shown ) > 10 else '' } "
257+ for parameter , shown in zip (info ["param_names" ], info ["params" ])
258+ )
259+ adapter_logger .debug (
260+ "%s: %d combination(s) of %s" , name , math .prod (len (shown ) for shown in info ["params" ]), values
261+ )
248262 if len (found ) > limit :
249263 adapter_logger .debug ("and %d more parametrized benchmark(s)" , len (found ) - limit )
250264
@@ -264,7 +278,9 @@ def note_case_ended(adapter_logger, status, timeout, native_path, *, parsed, ski
264278 adapter_logger .debug ("timed out after %g s: the process group was killed" , timeout )
265279 if not native_path .exists ():
266280 if not skipped :
267- adapter_logger .log (logging .WARNING if status == 0 else logging .DEBUG , "native output missing: %s" , native_path )
281+ adapter_logger .log (
282+ logging .WARNING if status == 0 else logging .DEBUG , "native output missing: %s" , native_path
283+ )
268284 elif not parsed :
269285 adapter_logger .warning ("native output does not parse: %s" , native_path )
270286
@@ -278,11 +294,17 @@ def run_bounded(args, *, timeout, what, scripts=None, temporary=(), **kwargs) ->
278294 `what` was being done: an order whose discovery cannot finish cannot be planned.
279295 `timeout` None means no limit.
280296 """
281- logger .debug ("%s: %s (in %s, limit %s)" , what , log .command (args , scripts = scripts , temporary = temporary ),
282- kwargs .get ("cwd" ) or Path .cwd (), f"{ timeout :g} s" if timeout else "none" )
297+ logger .debug (
298+ "%s: %s (in %s, limit %s)" ,
299+ what ,
300+ log .command (args , scripts = scripts , temporary = temporary ),
301+ kwargs .get ("cwd" ) or Path .cwd (),
302+ f"{ timeout :g} s" if timeout else "none" ,
303+ )
283304 started = time .monotonic ()
284- proc = subprocess .Popen (args , stdout = subprocess .PIPE , stderr = subprocess .PIPE , text = True ,
285- start_new_session = True , ** kwargs )
305+ proc = subprocess .Popen (
306+ args , stdout = subprocess .PIPE , stderr = subprocess .PIPE , text = True , start_new_session = True , ** kwargs
307+ )
286308 try :
287309 stdout , stderr = proc .communicate (timeout = timeout )
288310 except BaseException as error :
0 commit comments