diff --git a/.gitignore b/.gitignore index 75f473258..1a8c5990c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ *.bak *.d *.o +/benchmark/**/*.dat +/benchmark/*.pdf +/benchmark/*.png *.orig *.pdb *.rej diff --git a/Rakefile b/Rakefile index fee43217c..66f54a4e2 100644 --- a/Rakefile +++ b/Rakefile @@ -29,6 +29,8 @@ load "#{MRUBY_ROOT}/tasks/libmruby.rake" load "#{MRUBY_ROOT}/tasks/mrbgems_test.rake" load "#{MRUBY_ROOT}/test/mrbtest.rake" +load "#{MRUBY_ROOT}/tasks/benchmark.rake" + ############################## # generic build targets, rules task :default => :all diff --git a/benchmark/ao-render.rb b/benchmark/bm_ao_render.rb similarity index 99% rename from benchmark/ao-render.rb rename to benchmark/bm_ao_render.rb index 37bb4ad31..8212c3a13 100644 --- a/benchmark/ao-render.rb +++ b/benchmark/bm_ao_render.rb @@ -5,8 +5,8 @@ # mruby version by Hideki Miura # -IMAGE_WIDTH = 256 -IMAGE_HEIGHT = 256 +IMAGE_WIDTH = 64 +IMAGE_HEIGHT = 64 NSUBSAMPLES = 2 NAO_SAMPLES = 8 diff --git a/benchmark/fib39.rb b/benchmark/bm_fib.rb similarity index 72% rename from benchmark/fib39.rb rename to benchmark/bm_fib.rb index d5565b779..4b395f9cc 100644 --- a/benchmark/fib39.rb +++ b/benchmark/bm_fib.rb @@ -1,8 +1,7 @@ -# Fib 39 def fib n return n if n < 2 fib(n-2) + fib(n-1) end -puts fib(39) +puts fib(37) diff --git a/benchmark/bm_so_lists.rb b/benchmark/bm_so_lists.rb index f8d26797a..e8f4a2a5f 100644 --- a/benchmark/bm_so_lists.rb +++ b/benchmark/bm_so_lists.rb @@ -40,7 +40,7 @@ end i = 0 while i [bm_file, dat_dir, mruby_bin] do |task| + print bm_name + puts "..." + + data = (0...MRuby::BENCHMARK_REPEAT).map do |n| + str = %x{(time -f "%e %S %U" #{mruby_bin} #{bm_file}) 2>&1 >/dev/null} + str.split(' ').map(&:to_f) + end + + File.open(task.name, "w") do |f| + data = data.map {|_,r,s| (r + s) / 2.0} + min = data.min + max = data.max + avg = data.inject(&:+) / data.size + f.puts "#{bm_name.gsub('_', '-')} #{avg} #{min} #{max}" + end + end + end +end + +file plot_file => $dat_files do + plot +end + +task :benchmark => plot_file do + plot +end diff --git a/tasks/mruby_build.rake b/tasks/mruby_build.rake index 8438b6ca4..66608286d 100644 --- a/tasks/mruby_build.rake +++ b/tasks/mruby_build.rake @@ -8,6 +8,7 @@ module MRuby end def each_target(&block) + return to_enum(:each_target) if block.nil? @targets.each do |key, target| target.instance_eval(&block) end