@@ -277,23 +277,22 @@ def taskset_cmd(self) -> list[str]:
277277 """Returns a list of strings with taskset usage for core pinning.
278278 Pin compute benchmarks to a CPU cores set to ensure consistent results
279279 and non-zero CPU count measurements (e.g. avoid E-cores). Exactly 4 cores
280- with the maximum frequency are pinned by default to satisfy multiple threads benchmarks.
280+ are pinned by default to satisfy multiple threads benchmarks. It is assumed
281+ that they have the maximum, or at least the same, frequency.
281282 """
282- available_cores = Process ().cpu_affinity ()
283- core_frequencies = []
284- for core in available_cores : # type: ignore
285- with open (
286- f"/sys/devices/system/cpu/cpu{ core } /cpufreq/cpuinfo_max_freq"
287- ) as f :
288- freq = int (f .read ().strip ())
289- core_frequencies .append ((core , freq ))
290- selected = core_frequencies [:4 ] # first ones have highest frequency
291- if len ({freq for _ , freq in selected }) > 1 :
283+ get_core_frequency = (
284+ lambda num : open (
285+ f"/sys/devices/system/cpu/cpu{ num } /cpufreq/cpuinfo_max_freq"
286+ )
287+ .read ()
288+ .strip ()
289+ )
290+ selected_cores = [str (core ) for core in Process ().cpu_affinity ()[:4 ]] # type: ignore
291+ if len ({get_core_frequency (core ) for core in selected_cores }) > 1 :
292292 log .warning (
293- f"Selected cores for pinning have differing max frequencies: { selected } "
293+ f"Selected cores for pinning have differing max frequencies: { selected_cores } "
294294 )
295- cores_list = "," .join ([str (core ) for core , _ in selected ])
296- return ["taskset" , "-c" , cores_list ]
295+ return ["taskset" , "-c" , "," .join (selected_cores )]
297296
298297
299298class Suite (ABC ):
0 commit comments