From 57bb153456513d727f388bc4e6d9811dc1b4c79b Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 19 Jun 2013 22:33:02 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 +++++++++++++ common.mk | 12 ++++++++++-- tool/gcbench.rb | 24 ++++++++++++++++++++++++ tool/hashbench1.rb | 11 +++++++++++ tool/hashbench2.rb | 7 +++++++ tool/rdocbench.rb | 21 ++------------------- 6 files changed, 67 insertions(+), 21 deletions(-) create mode 100644 tool/gcbench.rb create mode 100644 tool/hashbench1.rb create mode 100644 tool/hashbench2.rb diff --git a/ChangeLog b/ChangeLog index e5dc432fc8..603bac1c82 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Thu Jun 20 07:30:35 2013 Koichi Sasada + + * 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 * tool/rdocbench.rb: add summary. diff --git a/common.mk b/common.mk index d89f82d45b..2a9f1a4c0c 100644 --- a/common.mk +++ b/common.mk @@ -426,9 +426,17 @@ rdoc-coverage: PHONY main 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 diff --git a/tool/gcbench.rb b/tool/gcbench.rb new file mode 100644 index 0000000000..e16cb9ddce --- /dev/null +++ b/tool/gcbench.rb @@ -0,0 +1,24 @@ + +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}" diff --git a/tool/hashbench1.rb b/tool/hashbench1.rb new file mode 100644 index 0000000000..3e8b0dd95e --- /dev/null +++ b/tool/hashbench1.rb @@ -0,0 +1,11 @@ +value = 0.01 +h = {} +n = 100_000 + +1.upto(n){|i| + h["%020d" % i] = value * i +} + +(n * 500).times{ + '' +} diff --git a/tool/hashbench2.rb b/tool/hashbench2.rb new file mode 100644 index 0000000000..e8c943fb21 --- /dev/null +++ b/tool/hashbench2.rb @@ -0,0 +1,7 @@ +value = 0.01 +h = {} +n = 4*(10**6) + +1.upto(n){|i| + h["%020d" % i] = value * i +} diff --git a/tool/rdocbench.rb b/tool/rdocbench.rb index f325f6a187..a248b9a9b7 100644 --- a/tool/rdocbench.rb +++ b/tool/rdocbench.rb @@ -1,28 +1,11 @@ - 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 }