ruby-changes:29406
From: ko1 <ko1@a...>
Date: Thu, 20 Jun 2013 07:33:13 +0900 (JST)
Subject: [ruby-changes:29406] ko1:r41458 (trunk): * common.mk: add new rules `gcbench-rdoc', `gcbench-hash'.
ko1 2013-06-20 07:33:02 +0900 (Thu, 20 Jun 2013) New Revision: 41458 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41458 Log: * common.mk: add new rules `gcbench-rdoc', `gcbench-hash'. * tool/gcbench.rb: separate GC bench framework and process. * tool/hashbench1.rb, tool/hashbench2.rb: add two types GC bench. hashbench1: many temporal objects (GC by newobj) hashbench2: hash size becomes bigger and bigger (GC by malloc) Two benchs are executed by `gcbench-hash' rule. * tool/rdocbench.rb: separated. Added files: trunk/tool/gcbench.rb trunk/tool/hashbench1.rb trunk/tool/hashbench2.rb Modified files: trunk/ChangeLog trunk/common.mk trunk/tool/rdocbench.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 41457) +++ ChangeLog (revision 41458) @@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Jun 20 07:30:35 2013 Koichi Sasada <ko1@a...> + + * common.mk: add new rules `gcbench-rdoc', `gcbench-hash'. + + * tool/gcbench.rb: separate GC bench framework and process. + + * tool/hashbench1.rb, tool/hashbench2.rb: add two types GC bench. + hashbench1: many temporal objects (GC by newobj) + hashbench2: hash size becomes bigger and bigger (GC by malloc) + Two benchs are executed by `gcbench-hash' rule. + + * tool/rdocbench.rb: separated. + Thu Jun 20 06:25:39 2013 Koichi Sasada <ko1@a...> * tool/rdocbench.rb: add summary. Index: common.mk =================================================================== --- common.mk (revision 41457) +++ common.mk (revision 41458) @@ -426,9 +426,17 @@ rdoc-coverage: PHONY main https://github.com/ruby/ruby/blob/trunk/common.mk#L426 RDOCBENCHOUT=/tmp/rdocbench -rdoc-bench: PHONY ruby +gcbench-rdoc: PHONY ruby @echo Benchmark with Generating RDoc documentation - $(Q) $(XRUBY) "$(srcdir)/tool/rdocbench.rb" --root "$(srcdir)" --page-dir "$(srcdir)/doc" --encoding=UTF-8 --no-force-update --all --ri --debug $(RDOCFLAGS) --quiet "$(srcdir)" + $(Q) $(XRUBY) "$(srcdir)/tool/gcbench.rb" "$(srcdir)/tool/rdocbench.rb" --root "$(srcdir)" --page-dir "$(srcdir)/doc" --encoding=UTF-8 --no-force-update --all --ri --debug $(RDOCFLAGS) --quiet "$(srcdir)" + +HASHBENCH_TYPE=1 +gcbench-hash: PHONY ruby + @echo "Benchmark with hashbench1 (many temporal objects / obj count intensive)" + $(Q) $(XRUBY) "$(srcdir)/tool/gcbench.rb" "$(srcdir)/tool/hashbench1.rb" + @echo + @echo "Benchmark with hashbench2 (increasing hash size / malloc intensive)" + $(Q) $(XRUBY) "$(srcdir)/tool/gcbench.rb" "$(srcdir)/tool/hashbench2.rb" nodoc: PHONY Index: tool/rdocbench.rb =================================================================== --- tool/rdocbench.rb (revision 41457) +++ tool/rdocbench.rb (revision 41458) @@ -1,28 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/tool/rdocbench.rb#L1 - require 'rdoc/rdoc' require 'tmpdir' -require 'benchmark' -require 'pp' Dir.mktmpdir('rdocbench-'){|d| dir = File.join(d, 'rdocbench') args = ARGV.dup args << '--op' << dir - GC::Profiler.enable - tms = Benchmark.measure{|x| - r = RDoc::RDoc.new - r.document args - } - GC::Profiler.report - pp GC.stat - puts - puts Benchmark::CAPTION - puts tms - puts "GC total time (sec): #{GC::Profiler.total_time}" - puts - puts "Summary (ruby): #{RUBY_DESCRIPTION})" - puts "Summary (real): #{tms.real} sec" - puts "Summary (gctm): #{GC::Profiler.total_time} sec" - puts "Summary (gc#) : #{GC.count}" + r = RDoc::RDoc.new + r.document args } Index: tool/hashbench1.rb =================================================================== --- tool/hashbench1.rb (revision 0) +++ tool/hashbench1.rb (revision 41458) @@ -0,0 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/tool/hashbench1.rb#L1 +value = 0.01 +h = {} +n = 100_000 + +1.upto(n){|i| + h["%020d" % i] = value * i +} + +(n * 500).times{ + '' +} Index: tool/gcbench.rb =================================================================== --- tool/gcbench.rb (revision 0) +++ tool/gcbench.rb (revision 41458) @@ -0,0 +1,24 @@ https://github.com/ruby/ruby/blob/trunk/tool/gcbench.rb#L1 + +require 'benchmark' +require 'pp' + +script = ARGV.shift || raise + +GC::Profiler.enable +tms = Benchmark.measure{|x| + load script +} +GC::Profiler.report +pp GC.stat + +gc_time = GC::Profiler.total_time + +puts +puts Benchmark::CAPTION +puts tms +puts "GC total time (sec): #{gc_time}" +puts +puts "Summary (ruby): #{RUBY_DESCRIPTION} (#{script})" +puts "Summary (real): #{tms.real} sec" +puts "Summary (gctm): #{gc_time} sec" +puts "Summary (gc#) : #{GC.count}" Index: tool/hashbench2.rb =================================================================== --- tool/hashbench2.rb (revision 0) +++ tool/hashbench2.rb (revision 41458) @@ -0,0 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/tool/hashbench2.rb#L1 +value = 0.01 +h = {} +n = 4*(10**6) + +1.upto(n){|i| + h["%020d" % i] = value * i +} -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/