@@ -65,18 +65,7 @@ def run
6565 ENV [ "RESULT_JSON_PATH" ] = result_json_path
6666
6767 # Set up the benchmarking command
68- cmd = [ ]
69- if linux?
70- cmd += setarch_prefix
71-
72- # Pin the process to one given core to improve caching and reduce variance on CRuby
73- # Other Rubies need to use multiple cores, e.g., for JIT threads
74- if ruby_description . start_with? ( 'ruby ' ) && !no_pinning
75- # The last few cores of Intel CPU may be slow E-Cores, so avoid using the last one.
76- cpu = [ ( Etc . nprocessors / 2 ) - 1 , 0 ] . max
77- cmd += [ "taskset" , "-c" , "#{ cpu } " ]
78- end
79- end
68+ cmd = base_cmd
8069
8170 # Fix for jruby/jruby#7394 in JRuby 9.4.2.0
8271 script_path = File . expand_path ( script_path )
@@ -169,6 +158,27 @@ def linux?
169158 @linux ||= RbConfig ::CONFIG [ 'host_os' ] =~ /linux/
170159 end
171160
161+ # Set up the base command with CPU pinning if needed
162+ def base_cmd
163+ @base_cmd ||= begin
164+ cmd = [ ]
165+
166+ if linux?
167+ cmd += setarch_prefix
168+
169+ # Pin the process to one given core to improve caching and reduce variance on CRuby
170+ # Other Rubies need to use multiple cores, e.g., for JIT threads
171+ if ruby_description . start_with? ( 'ruby ' ) && !no_pinning
172+ # The last few cores of Intel CPU may be slow E-Cores, so avoid using the last one.
173+ cpu = [ ( Etc . nprocessors / 2 ) - 1 , 0 ] . max
174+ cmd += [ "taskset" , "-c" , "#{ cpu } " ]
175+ end
176+ end
177+
178+ cmd
179+ end
180+ end
181+
172182 # Generate setarch prefix for Linux
173183 def setarch_prefix
174184 # Disable address space randomization (for determinism)
0 commit comments