From dfddb040635eebc200ba6a4df92ce08cf79d2243 Mon Sep 17 00:00:00 2001 From: dearblue Date: Sun, 6 Mar 2022 15:27:50 +0900 Subject: [PATCH 1/4] Use standardized approach for get build configuration name --- tasks/benchmark.rake | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tasks/benchmark.rake b/tasks/benchmark.rake index 12e0d4602..271b645f2 100644 --- a/tasks/benchmark.rake +++ b/tasks/benchmark.rake @@ -9,11 +9,8 @@ def bm_files end def build_config_name - if !ENV['MRUBY_CONFIG'].to_s.empty? - File.basename(ENV['MRUBY_CONFIG'], '.rb').gsub('build_config_', '') - else - "bm" - end + path = MRuby::Build.mruby_config_path + File.basename(path, '.rb').gsub('build_config_', '') end def plot_file From e39581242db8f873eea3b3cc95605b35ce4f3d0e Mon Sep 17 00:00:00 2001 From: dearblue Date: Sun, 6 Mar 2022 15:28:56 +0900 Subject: [PATCH 2/4] Display file paths for benchmark results --- tasks/benchmark.rake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/benchmark.rake b/tasks/benchmark.rake index 271b645f2..a10718435 100644 --- a/tasks/benchmark.rake +++ b/tasks/benchmark.rake @@ -43,6 +43,8 @@ def plot p.puts "e" end end + + puts "Benchmark results output to #{plot_file}" end From 1f0d265a830469598e68583334cc1f88e6f08103 Mon Sep 17 00:00:00 2001 From: dearblue Date: Sun, 6 Mar 2022 15:29:35 +0900 Subject: [PATCH 3/4] Raise an exception if there is no benchmark target --- tasks/benchmark.rake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/benchmark.rake b/tasks/benchmark.rake index a10718435..9dbd344e5 100644 --- a/tasks/benchmark.rake +++ b/tasks/benchmark.rake @@ -18,6 +18,8 @@ def plot_file end def plot + raise "no build target to benchmark against" if $dat_files.empty? + opts_file = "#{MRUBY_ROOT}/benchmark/plot.gpl" opts = File.read(opts_file).each_line.to_a.map(&:strip).join(';') From 267dd15767a18b433790117d7c6fc3f77c5a1b83 Mon Sep 17 00:00:00 2001 From: dearblue Date: Sun, 6 Mar 2022 15:35:05 +0900 Subject: [PATCH 4/4] Allow build settings to define if benchmarks are covered or not Each build target can be explicitly disabled from benchmarking with `MRuby::Build#disable_benchmark`. Also, the build target "host", which was previously excluded, is now included in the benchmark. --- lib/mruby/build.rb | 9 +++++++++ tasks/benchmark.rake | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 66005a6df..771aa7f3e 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -123,6 +123,7 @@ module MRuby @enable_test = false @enable_lock = true @enable_presym = true + @enable_benchmark = true @mrbcfile_external = false @internal = internal @toolchains = [] @@ -232,6 +233,14 @@ module MRuby @cxx_abi_enabled = true end + def benchmark_enabled? + @enable_benchmark + end + + def disable_benchmark + @enable_benchmark = false + end + def compile_as_cxx(src, cxx_src = nil, obj = nil, includes = []) # # If `cxx_src` is specified, this method behaves the same as before as diff --git a/tasks/benchmark.rake b/tasks/benchmark.rake index 9dbd344e5..b32d165bf 100644 --- a/tasks/benchmark.rake +++ b/tasks/benchmark.rake @@ -51,7 +51,7 @@ end MRuby.each_target do |target| - next if target.name == 'host' || target.internal? + next if !target.benchmark_enabled? || target.internal? mruby_bin = "#{target.build_dir}/bin/mruby" bm_files.each do |bm_file|