1515require_relative 'lib/table_formatter'
1616require_relative 'lib/benchmark_filter'
1717
18- # Checked system - error or return info if the command fails
19- def check_call ( command , env : { } , raise_error : true , quiet : false )
20- puts ( "+ #{ command } " ) unless quiet
21-
22- result = { }
23-
24- result [ :success ] = system ( env , command )
25- result [ :status ] = $?
26-
27- unless result [ :success ]
28- puts "Command #{ command . inspect } failed with exit code #{ result [ :status ] . exitstatus } in directory #{ Dir . pwd } "
29- raise RuntimeError . new if raise_error
30- end
31-
32- result
33- end
34-
3518def check_output ( *command )
3619 IO . popen ( *command , &:read )
3720end
@@ -46,17 +29,17 @@ def set_bench_config(turbo:)
4629 # sudo requires the flag '-S' in order to take input from stdin
4730 if File . exist? ( '/sys/devices/system/cpu/intel_pstate' ) # Intel
4831 unless intel_no_turbo? || turbo
49- check_call ( "sudo -S sh -c 'echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo'" )
50- at_exit { check_call ( "sudo -S sh -c 'echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo'" , quiet : true ) }
32+ BenchmarkRunner . check_call ( "sudo -S sh -c 'echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo'" )
33+ at_exit { BenchmarkRunner . check_call ( "sudo -S sh -c 'echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo'" , quiet : true ) }
5134 end
5235 # Disabling Turbo Boost reduces the CPU frequency, so this should be run after that.
53- check_call ( "sudo -S sh -c 'echo 100 > /sys/devices/system/cpu/intel_pstate/min_perf_pct'" ) unless intel_perf_100pct?
36+ BenchmarkRunner . check_call ( "sudo -S sh -c 'echo 100 > /sys/devices/system/cpu/intel_pstate/min_perf_pct'" ) unless intel_perf_100pct?
5437 elsif File . exist? ( '/sys/devices/system/cpu/cpufreq/boost' ) # AMD
5538 unless amd_no_boost? || turbo
56- check_call ( "sudo -S sh -c 'echo 0 > /sys/devices/system/cpu/cpufreq/boost'" )
57- at_exit { check_call ( "sudo -S sh -c 'echo 1 > /sys/devices/system/cpu/cpufreq/boost'" , quiet : true ) }
39+ BenchmarkRunner . check_call ( "sudo -S sh -c 'echo 0 > /sys/devices/system/cpu/cpufreq/boost'" )
40+ at_exit { BenchmarkRunner . check_call ( "sudo -S sh -c 'echo 1 > /sys/devices/system/cpu/cpufreq/boost'" , quiet : true ) }
5841 end
59- check_call ( "sudo -S cpupower frequency-set -g performance" ) unless performance_governor?
42+ BenchmarkRunner . check_call ( "sudo -S cpupower frequency-set -g performance" ) unless performance_governor?
6043 end
6144end
6245
@@ -230,7 +213,7 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
230213 end
231214
232215 # Do the benchmarking
233- result = check_call ( cmd . shelljoin , env : env , raise_error : false )
216+ result = BenchmarkRunner . check_call ( cmd . shelljoin , env : env , raise_error : false )
234217
235218 if result [ :success ]
236219 bench_data [ bench_name ] = JSON . parse ( File . read ( result_json_path ) ) . tap do |json |
0 commit comments