[前][次][番号順一覧][スレッド一覧][生データ]

yarv-diff:35

From: ko1 atdot.net
Date: 30 Jun 2005 14:36:28 -0000
Subject: [yarv-diff:35] r190 - in trunk: . benchmark rb

Author: ko1
Date: 2005-06-30 23:36:27 +0900 (Thu, 30 Jun 2005)
New Revision: 190

Modified:
   trunk/ChangeLog
   trunk/benchmark/run.rb
   trunk/rb/eval.rb
   trunk/rb/insns2vm.rb
Log:
	* rb/eval.rb : add and fix some rules

	* rb/insns2vm.rb : generate all

	* benchmark/run.rb : add -r (ruby only) option



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-06-30 14:32:22 UTC (rev 189)
+++ trunk/ChangeLog	2005-06-30 14:36:27 UTC (rev 190)
@@ -4,6 +4,15 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2005-06-30(Thu) 23:34:10 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* rb/eval.rb : add and fix some rules
+
+	* rb/insns2vm.rb : generate all
+
+	* benchmark/run.rb : add -r (ruby only) option
+
+
 2005-06-30(Thu) 23:25:23 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* tmpl/vmtc.inc.tmpl : add const prefix

Modified: trunk/benchmark/run.rb
===================================================================
--- trunk/benchmark/run.rb	2005-06-30 14:32:22 UTC (rev 189)
+++ trunk/benchmark/run.rb	2005-06-30 14:36:27 UTC (rev 190)
@@ -7,6 +7,8 @@
 require 'rbconfig'
 
 $yarvonly = false
+$rubyonly = false
+
 $results  = []
 
 puts "ruby #{RUBY_VERSION} #{RUBY_PLATFORM}(#{RUBY_RELEASE_DATE})"
@@ -20,11 +22,11 @@
 
   /[a-z]+_(.+)\.rb/ =~ file
   bm_name = $1
-  puts '-----------------------------------------------------------' unless $yarvonly
+  puts '-----------------------------------------------------------' unless $yarvonly || $rubyonly
   puts "#{bm_name}: "
   
   
-puts <<EOS unless $yarvonly
+puts <<EOS unless $yarvonly || $rubyonly
 #{prog}
 --
 EOS
@@ -33,11 +35,11 @@
   begin
     Benchmark.bm{|x|
     # x.report("yarv"){ YARVUtil.load_bm(file) }
-    } unless $yarvonly
+    } unless $yarvonly || $rubyonly
 
     result = [bm_name]
     result << ruby_exec(file) unless $yarvonly
-    result << yarv_exec(file)
+    result << yarv_exec(file) unless $rubyonly
     $results << result
     
     # puts YARVUtil.parse(File.read(file), file, 1).disasm
@@ -98,6 +100,8 @@
   ARGV.each{|arg|
     if /\A(--yarv)|(-y)/ =~ arg
       $yarvonly = true
+    elsif /\A(--ruby)|(-r)/ =~ arg
+      $rubyonly = true
     end
   }
   ARGV.delete_if{|arg|

Modified: trunk/rb/eval.rb
===================================================================
--- trunk/rb/eval.rb	2005-06-30 14:32:22 UTC (rev 189)
+++ trunk/rb/eval.rb	2005-06-30 14:36:27 UTC (rev 190)
@@ -24,10 +24,11 @@
   o = opts.dup
   opts.delete(opt)
   o
-} + []
+} + [[]]
 
 pp Configs if $DEBUG
 
+
 def exec_cmd(cmd)
   unless system(cmd)
     p cmd
@@ -58,15 +59,88 @@
   }
 end
 
+def bench_each idx
+  puts "= #{idx}"
+  5.times{|count|
+    FileUtils.cd(dirname(idx)){
+      exec_cmd("make benchmark BOPT=-y > ../b#{idx}-#{count}")
+    }
+  }
+end
+
 def bench
+  # return bench_each(6)
   Configs.each_with_index{|c, idx|
-    puts "= #{idx}"
-    FileUtils.cd(dirname(idx)){
-      exec_cmd("make benchmark BOPT=-y > ../b#{idx}")
+    bench_each idx
+  }
+end
+
+def parse_result data
+  flag = false
+  stat = []
+  data.each{|line|
+    if flag
+      if /(\w+)\t([\d\.]+)/ =~ line
+        stat << [$1, $2.to_f]
+      else
+        raise "not a data"
+      end
+      
+    end
+    if /benchmark summary/ =~ line
+      flag = true
+    end
+  }
+  stat
+end
+
+def calc_each data
+  data.sort!
+  data.pop   # remove max
+  data.shift # remove min
+
+  data.inject(0.0){|res, e|
+    res += e
+  } / data.size
+end
+
+def calc_stat stats
+  stat = []
+  stats[0].each_with_index{|e, idx|
+    bm = e[0]
+    vals = stats.map{|st|
+      st[idx][1]
     }
+    [bm, calc_each(vals)]
   }
 end
 
+def stat
+  total = []
+  Configs.each_with_index{|c, idx|
+    stats = []
+    5.times{|count|
+      file = "b#{idx}-#{count}"
+      # p file
+      open(file){|f|
+        stats << parse_result(f.read)
+      }
+    }
+    # merge stats
+    total << calc_stat(stats)
+    total
+  }
+  # pp total
+  total[0].each_with_index{|e, idx|
+    bm = e[0]
+    # print "#{bm}\t"
+    total.each{|st|
+      print st[idx][1], "\t"
+    }
+    puts
+  }
+end
+
 ARGV.each{|cmd|
   case cmd
   when 'build'
@@ -75,6 +149,10 @@
     check
   when 'bench'
     bench
+  when 'stat'
+    stat
+  else
+    raise
   end
 }
 

Modified: trunk/rb/insns2vm.rb
===================================================================
--- trunk/rb/insns2vm.rb	2005-06-30 14:32:22 UTC (rev 189)
+++ trunk/rb/insns2vm.rb	2005-06-30 14:36:27 UTC (rev 190)
@@ -280,7 +280,7 @@
 
   def make_unified_insns insns
 
-    if false # || true # all optimized insn
+    if false  || true # all optimized insn
       insn_sets = insns.map{|insn|
         [insn] + insn.optimized
       }


--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧][生データ]