summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2015-04-27 00:54:36 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2015-04-27 00:54:36 +0900
commitf1164487e1427c40e3a10ef0902a5905acc5f08a (patch)
tree68cad329ff30c6cb8a8ddf9a7db3f355057f6546
parentbdb9d4d19c3120666aae2ae24602f2d5dec19bbd (diff)
parented3a25337226015ba0356a9027e0e4965b5788b3 (diff)
downloadmruby-f1164487e1427c40e3a10ef0902a5905acc5f08a.tar.gz
mruby-f1164487e1427c40e3a10ef0902a5905acc5f08a.zip
Merge branch 'master' of github.com:mruby/mruby
-rw-r--r--.gitignore3
-rw-r--r--Rakefile2
-rw-r--r--benchmark/bm_ao_render.rb (renamed from benchmark/ao-render.rb)4
-rw-r--r--benchmark/bm_fib.rb (renamed from benchmark/fib39.rb)3
-rw-r--r--benchmark/bm_so_lists.rb2
-rw-r--r--benchmark/build_config_boxing.rb28
-rw-r--r--benchmark/build_config_cc.rb13
-rw-r--r--benchmark/plot.gpl5
-rw-r--r--tasks/benchmark.rake91
-rw-r--r--tasks/mruby_build.rake1
10 files changed, 147 insertions, 5 deletions
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
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
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<NUM
- i+=1
+ i += 1
result = test_lists()
end
diff --git a/benchmark/build_config_boxing.rb b/benchmark/build_config_boxing.rb
new file mode 100644
index 000000000..b478c9005
--- /dev/null
+++ b/benchmark/build_config_boxing.rb
@@ -0,0 +1,28 @@
+MRuby::Build.new do |conf|
+ toolchain :gcc
+end
+
+MRuby::Build.new('no_boxing') do |conf|
+ toolchain :gcc
+
+ conf.gembox 'default'
+end
+
+MRuby::Build.new('word_boxing') do |conf|
+ toolchain :gcc
+
+ conf.gembox 'default'
+ conf.compilers.each do |c|
+ c.defines += %w(MRB_WORD_BOXING)
+ end
+end
+
+MRuby::Build.new('nan_boxing') do |conf|
+ toolchain :gcc
+
+ conf.gembox 'default'
+ conf.compilers.each do |c|
+ c.defines += %w(MRB_NAN_BOXING)
+ end
+end
+
diff --git a/benchmark/build_config_cc.rb b/benchmark/build_config_cc.rb
new file mode 100644
index 000000000..56d725bc7
--- /dev/null
+++ b/benchmark/build_config_cc.rb
@@ -0,0 +1,13 @@
+MRuby::Build.new do |conf|
+ toolchain :gcc
+end
+
+MRuby::Build.new('gcc') do |conf|
+ toolchain :gcc
+ conf.gembox 'default'
+end
+
+MRuby::Build.new('clang') do |conf|
+ toolchain :clang
+ conf.gembox 'default'
+end
diff --git a/benchmark/plot.gpl b/benchmark/plot.gpl
new file mode 100644
index 000000000..725e2ec1c
--- /dev/null
+++ b/benchmark/plot.gpl
@@ -0,0 +1,5 @@
+set yrange [0:]
+set terminal pngcairo font 'Sans, 8' lw 1 size 1400,1024
+set xtics rotate by -45
+set style histogram errorbars gap 2 lw 1
+set style fill solid border -1
diff --git a/tasks/benchmark.rake b/tasks/benchmark.rake
new file mode 100644
index 000000000..84e69ebee
--- /dev/null
+++ b/tasks/benchmark.rake
@@ -0,0 +1,91 @@
+module MRuby
+ BENCHMARK_REPEAT = 4
+end
+
+$dat_files = []
+
+def bm_files
+ Dir.glob("#{MRUBY_ROOT}/benchmark/bm_*.rb")
+end
+
+def build_config_name
+ if ENV['MRUBY_CONFIG']
+ File.basename(ENV['MRUBY_CONFIG'], '.rb').gsub('build_config_', '')
+ else
+ "build"
+ end
+end
+
+def plot_file
+ File.join(MRUBY_ROOT, 'benchmark', "#{build_config_name}.png")
+end
+
+def plot
+ opts_file = "#{MRUBY_ROOT}/benchmark/plot.gpl"
+ opts = File.read(opts_file).each_line.to_a.map(&:strip).join(';')
+
+ dat_files = $dat_files.group_by {|f| File.dirname(f).split(File::SEPARATOR)[-1]}
+
+ opts += ";set output '#{plot_file}'"
+
+ opts += ';plot '
+
+ opts += dat_files.keys.map do |data_file|
+ %Q['-' u 2:3:4:xtic(1) w hist title columnheader(1)]
+ end.join(',')
+ opts += ';'
+
+ cmd = %Q{gnuplot -p -e "#{opts}"}
+
+ IO.popen(cmd, 'w') do |p|
+ dat_files.each do |target_name, bm_files|
+ p.puts target_name.gsub('_', '-')
+ bm_files.each do |bm_file|
+ p.write File.read(bm_file)
+ end
+ p.puts "e"
+ end
+ end
+end
+
+
+MRuby.each_target do |target|
+ next if target.name == 'host'
+ mruby_bin = "#{target.build_dir}/bin/mruby"
+
+ bm_files.each do |bm_file|
+ bm_name = File.basename bm_file, ".rb"
+
+ dat_dir = File.join('benchmark', build_config_name, target.name)
+ dat_file = File.join(dat_dir, "#{bm_name}.dat")
+ $dat_files << dat_file
+
+ directory dat_dir
+
+ file dat_file => [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