From d22d3b5a7a37bc2ff723fa5acc4ce2d85539d189 Mon Sep 17 00:00:00 2001 From: ko1 Date: Fri, 5 Jan 2007 13:52:16 +0000 Subject: [PATCH] * benchmark/bm_app_pentomino.rb : use Array#dup instead of Array#clone * benchmark/bmx_temp.rb : removed * benchmark/run.rb : use run.rb instead of run_rite.rb * common.mk : ditto * benchmark/run_rite.rb : removed * common.mk : use $(srcdir)/test.rb to run a test program with "make run" * benchmark/bmx_temp.rb : removed and set svn:ignore (bmx_*.rb) to benchmark/ * test.rb : set svn:ignore git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 21 ++++++ benchmark/bm_app_pentomino.rb | 8 +-- benchmark/bmx_temp.rb | 57 --------------- benchmark/run.rb | 90 +++++++++++------------- benchmark/run_rite.rb | 129 ---------------------------------- common.mk | 25 ++++--- vm.c | 4 +- 7 files changed, 80 insertions(+), 254 deletions(-) delete mode 100644 benchmark/bmx_temp.rb delete mode 100644 benchmark/run_rite.rb diff --git a/ChangeLog b/ChangeLog index 4eb6006079..48d6dd5c17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +Fri Jan 5 22:21:08 2007 Koichi Sasada + + * benchmark/bm_app_pentomino.rb : use Array#dup instead of + Array#clone + + * benchmark/bmx_temp.rb : removed + + * benchmark/run.rb : use run.rb instead of run_rite.rb + + * common.mk : ditto + + * benchmark/run_rite.rb : removed + + * common.mk : use $(srcdir)/test.rb to run a test program + with "make run" + + * benchmark/bmx_temp.rb : removed and + set svn:ignore (bmx_*.rb) to benchmark/ + + * test.rb : set svn:ignore + Fri Jan 5 21:03:08 2007 Koichi Sasada * yarvtest/yarvtest.rb : fix to compare results diff --git a/benchmark/bm_app_pentomino.rb b/benchmark/bm_app_pentomino.rb index 0fc80fade9..4aa144542a 100644 --- a/benchmark/bm_app_pentomino.rb +++ b/benchmark/bm_app_pentomino.rb @@ -18,7 +18,7 @@ def piece(n, a, nb) if n == NP-1 $p << [a.sort] else - nbc=nb.clone + nbc=nb.dup [-ROW, -1, 1, ROW].each{|d| if x+d > 0 and not a.include?(x+d) and not nbc.include?(x+d) nbc << x+d @@ -113,7 +113,7 @@ def setpiece(a,pos) $b[pos+s] = i } a << i - setpiece(a.clone, pos) + setpiece(a.dup, pos) a.pop x.each{|s| $b[pos+s] = -1 @@ -148,7 +148,7 @@ def piece(n,a,nb) if n == NP-1 $p << [a.sort] else - nbc=nb.clone + nbc=nb.dup for d in [-ROW, -1, 1, ROW] if x+d > 0 and not a.include?(x+d) and not nbc.include?(x+d) nbc << x+d @@ -242,7 +242,7 @@ def setpiece(a,pos) $b[pos+s] = i end a << i - setpiece(a.clone, pos) + setpiece(a.dup, pos) a.pop for s in x do $b[pos+s] = -1 diff --git a/benchmark/bmx_temp.rb b/benchmark/bmx_temp.rb deleted file mode 100644 index dc45f5a153..0000000000 --- a/benchmark/bmx_temp.rb +++ /dev/null @@ -1,57 +0,0 @@ - -i=0 -while i<20000000 - x = 1 # "foo" - i+=1 -end - -__END__ - -class Range - def each - f = self.first - l = self.last - while f < l - yield - f = f.succ - end - end -end - -(0..10000000).each{ -} - -__END__ -class Fixnum_ - def times - i = 0 - while i exec_command_error_variable - puts "\t" + exec_command_error_variable.message - end - EOP -end - -def benchmark prog - rubybin = ENV['RUBY'] || File.join( - Config::CONFIG["bindir"], - Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"]) - - # - tmpfile = Tempfile.new('yarvbench') - tmpfile.write(prog) - tmpfile.close - - cmd = "#{rubybin} #{tmpfile.path}" - result = `#{cmd}` - puts result - tmpfile.close(true) - result +def benchmark file, bin + m = Benchmark.measure{ + `#{bin} #{$opts} #{file}` + } + sec = '%.3f' % m.real + puts " #{sec}" + sec end def ruby_exec file - prog = exec_command 'ruby', file, 'load' - benchmark prog + print 'ruby' + benchmark file, $ruby_program end def yarv_exec file - prog = exec_command 'yarv', file, 'YARVUtil.load_bm' - benchmark prog + print 'yarv' + benchmark file, $yarv_program end if $0 == __FILE__ ARGV.each{|arg| - if /\A(--yarv)|(-y)/ =~ arg + case arg + when /\A--yarv-program=(.+)/ + $yarv_program = $1 + when /\A--ruby-program=(.+)/ + $ruby_program = $1 + when /\A--opts=(.+)/ + $opts = $1 + when /\A(--yarv)|(-y)/ $yarvonly = true - elsif /\A(--ruby)|(-r)/ =~ arg + when /\A(--ruby)|(-r)/ $rubyonly = true end } @@ -109,6 +96,12 @@ if $0 == __FILE__ /\A-/ =~ arg } + puts "Ruby:" + system("#{$ruby_program} -v") + puts + puts "YARV:" + system("#{$yarv_program} -v") + if ARGV.empty? Dir.glob(File.dirname(__FILE__) + '/bm_*.rb').sort.each{|file| bm file @@ -134,4 +127,3 @@ if $0 == __FILE__ } end - diff --git a/benchmark/run_rite.rb b/benchmark/run_rite.rb deleted file mode 100644 index 7a8d268b24..0000000000 --- a/benchmark/run_rite.rb +++ /dev/null @@ -1,129 +0,0 @@ -# -# YARV benchmark driver -# - -require 'benchmark' -require 'rbconfig' - -$yarvonly = false -$rubyonly = false - -$results = [] - -# prepare 'wc.input' -def prepare_wc_input - wcinput = File.join(File.dirname($0), 'wc.input') - wcbase = File.join(File.dirname($0), 'wc.input.base') - unless FileTest.exist?(wcinput) - data = File.read(wcbase) - 13.times{ - data << data - } - open(wcinput, 'w'){|f| f.write data} - end -end - -prepare_wc_input - -def bm file - prog = File.readlines(file).map{|e| e.rstrip}.join("\n") - return if prog.empty? - - /[a-z]+_(.+)\.rb/ =~ file - bm_name = $1 - puts '-----------------------------------------------------------' unless $yarvonly || $rubyonly - puts "#{bm_name}: " - - -puts < e - puts - puts "** benchmark failure: #{e}" - puts e.backtrace - end -end - -def benchmark file, bin - m = Benchmark.measure{ - `#{bin} #{$opts} #{file}` - } - sec = '%.3f' % m.real - puts " #{sec}" - sec -end - -def ruby_exec file - print 'ruby' - benchmark file, $ruby_program -end - -def yarv_exec file - print 'yarv' - benchmark file, $yarv_program -end - -if $0 == __FILE__ - ARGV.each{|arg| - case arg - when /\A--yarv-program=(.+)/ - $yarv_program = $1 - when /\A--ruby-program=(.+)/ - $ruby_program = $1 - when /\A--opts=(.+)/ - $opts = $1 - when /\A(--yarv)|(-y)/ - $yarvonly = true - when /\A(--ruby)|(-r)/ - $rubyonly = true - end - } - ARGV.delete_if{|arg| - /\A-/ =~ arg - } - - puts "Ruby:" - system("#{$ruby_program} -v") - puts - puts "YARV:" - system("#{$yarv_program} -v") - - if ARGV.empty? - Dir.glob(File.dirname(__FILE__) + '/bm_*.rb').sort.each{|file| - bm file - } - else - ARGV.each{|file| - Dir.glob(File.join(File.dirname(__FILE__), file + '*')){|ef| - # file = "#{File.dirname(__FILE__)}/#{file}.rb" - bm ef - } - } - end - - puts - puts "-- benchmark summary ---------------------------" - $results.each{|res| - print res.shift, "\t" - (res||[]).each{|result| - /([\d\.]+)/ =~ result - print $1 + "\t" if $1 - } - puts - } -end - diff --git a/common.mk b/common.mk index 7ce6bd9779..99b83350bb 100644 --- a/common.mk +++ b/common.mk @@ -562,32 +562,31 @@ incs: docs: $(BASERUBY) -I$(srcdir) $(srcdir)/tool/makedocs.rb $(INSNS2VMOPT) +## + compare-test: miniruby$(EXEEXT) $(BASERUBY) -I$(srcdir) $(srcdir)/yarvtest/runner.rb $(OPT) ruby=$(MINIRUBY) matzruby=$(MATZRUBY) compare-test-each: miniruby$(EXEEXT) $(BASERUBY) -I$(srcdir) $(srcdir)/yarvtest/test_$(ITEM).rb $(OPT) ruby=$(MINIRUBY) matzruby=$(MATZRUBY) -allload: miniruby$(EXEEXT) - $(MINIRUBY) -I$(srcdir) $(srcdir)/tool/allload.rb `$(BASERUBY) -rrbconfig -e 'print Config::CONFIG["rubylibdir"]'` - run: miniruby$(EXEEXT) - $(MINIRUBY) -I$(srcdir)/lib test.rb $(RUNOPT) + $(MINIRUBY) -I$(srcdir)/lib $(srcdir)/test.rb $(RUNOPT) runruby: $(RUBY) - ./$(RUBY) -I$(srcdir)/lib -I. $(srcdir)/tool/runruby.rb test.rb + ./$(RUBY) -I$(srcdir)/lib -I. $(srcdir)/tool/runruby.rb $(srcdir)/test.rb parse: miniruby$(EXEEXT) - $(MINIRUBY) $(srcdir)/tool/parse.rb test.rb + $(MINIRUBY) $(srcdir)/tool/parse.rb $(srcdir)/test.rb benchmark: $(RUBY) - $(BASERUBY) -I$(srcdir) -I$(srcdir)/lib $(srcdir)/benchmark/run_rite.rb $(OPT) $(ITEMS) --yarv-program=./$(PROGRAM) --ruby-program=$(BASERUBY) --opts=-I$(srcdir)/lib + $(BASERUBY) -I$(srcdir) -I$(srcdir)/lib $(srcdir)/benchmark/run.rb $(OPT) $(ITEMS) --yarv-program=./$(PROGRAM) --ruby-program=$(BASERUBY) --opts=-I$(srcdir)/lib -tbench: prog - $(BASERUBY) -I$(srcdir) -I$(srcdir)/lib $(srcdir)/benchmark/run_rite.rb bmx $(OPT) --yarv-program=./$(PROGRAM) --ruby-program=$(BASERUBY) --opts=-I$(srcdir)/lib +benchmark-each: $(RUBY) + $(BASERUBY) -I$(srcdir) $(srcdir)/benchmark/run.rb bm_$(ITEM) $(OPT) --yarv-program=./$(RUBY) --ruby-program=$(BASERUBY) --opts=-I$(srcdir)/lib -bench-each: $(RUBY) - $(BASERUBY) -I$(srcdir) $(srcdir)/benchmark/run_rite.rb bm_$(ITEM) $(OPT) --yarv-program=./$(RUBY) --ruby-program=$(BASERUBY) --opts=-I$(srcdir)/lib +tbench: $(RUBY) + $(BASERUBY) -I$(srcdir) -I$(srcdir)/lib $(srcdir)/benchmark/run.rb bmx $(OPT) --yarv-program=./$(PROGRAM) --ruby-program=$(BASERUBY) --opts=-I$(srcdir)/lib aotc: $(RUBY) -I$(srcdir) -I. $(srcdir)/tool/aotcompile.rb $(INSNS2VMOPT) @@ -605,12 +604,12 @@ run.gdb: echo run >> run.gdb gdb: miniruby$(EXEEXT) run.gdb - gdb -x run.gdb --quiet --args $(MINIRUBY) -I$(srcdir)/lib test.rb + gdb -x run.gdb --quiet --args $(MINIRUBY) -I$(srcdir)/lib $(srcdir)/test.rb # Intel VTune vtune: miniruby$(EXEEXT) - vtl activity -c sampling -app ".\miniruby$(EXEEXT)","-I$(srcdir)/lib test.rb" run + vtl activity -c sampling -app ".\miniruby$(EXEEXT)","-I$(srcdir)/lib $(srcdir)/test.rb" run vtl view -hf -mn miniruby$(EXEEXT) -sum -sort -cd vtl view -ha -mn miniruby$(EXEEXT) -sum -sort -cd | $(BASERUBY) $(srcdir)/tool/vtlh.rb > ha.lines diff --git a/vm.c b/vm.c index fb2464a113..5c6a20b93f 100644 --- a/vm.c +++ b/vm.c @@ -236,7 +236,7 @@ th_make_env_each(yarv_thread_t *th, yarv_control_frame_t *cfp, for (i = 0; i <= local_size; i++) { env->env[i] = envptr[-local_size + i]; - //dp(env->env[i]); + // dp(env->env[i]); if (YARV_NORMAL_ISEQ_P(cfp->iseq)) { /* clear value stack for GC */ // envptr[-local_size + i] = 0; @@ -707,7 +707,7 @@ th_invoke_proc(yarv_thread_t *th, yarv_proc_t *proc, volatile int stored_safe = th->safe_level; volatile NODE *stored_special_cref_stack = 0; yarv_control_frame_t * volatile cfp = th->cfp; - + TH_PUSH_TAG(th); if ((state = EXEC_TAG()) == 0) { stored_special_cref_stack =