From 99b10ff471c50358ed0f6864f4cf87857c51a91d Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 20 Jun 2013 06:18:09 +0000 Subject: * benchmark/gc: create a directory to store GC related benchmark. * benchmark/gc/gcbench.rb: moved from tool/gcbench.rb. * benchmark/gc/hash(1|2).rb: ditto. * benchmark/gc/rdoc.rb: ditto. * benchmark/gc/null.rb: added. * common.mk: fix rule. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 14 ++++++++++++++ benchmark/gc/gcbench.rb | 27 +++++++++++++++++++++++++++ benchmark/gc/hash1.rb | 11 +++++++++++ benchmark/gc/hash2.rb | 7 +++++++ benchmark/gc/null.rb | 1 + benchmark/gc/rdoc.rb | 13 +++++++++++++ common.mk | 16 +++++----------- tool/gcbench.rb | 22 ---------------------- tool/hashbench1.rb | 11 ----------- tool/hashbench2.rb | 7 ------- tool/rdocbench.rb | 11 ----------- 11 files changed, 78 insertions(+), 62 deletions(-) create mode 100644 benchmark/gc/gcbench.rb create mode 100644 benchmark/gc/hash1.rb create mode 100644 benchmark/gc/hash2.rb create mode 100644 benchmark/gc/null.rb create mode 100644 benchmark/gc/rdoc.rb delete mode 100644 tool/gcbench.rb delete mode 100644 tool/hashbench1.rb delete mode 100644 tool/hashbench2.rb delete mode 100644 tool/rdocbench.rb diff --git a/ChangeLog b/ChangeLog index 6ed66c2a86..58fd2da365 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Thu Jun 20 15:14:00 2013 Koichi Sasada + + * benchmark/gc: create a directory to store GC related benchmark. + + * benchmark/gc/gcbench.rb: moved from tool/gcbench.rb. + + * benchmark/gc/hash(1|2).rb: ditto. + + * benchmark/gc/rdoc.rb: ditto. + + * benchmark/gc/null.rb: added. + + * common.mk: fix rule. + Thu Jun 20 14:09:54 2013 Koichi Sasada * tool/hashbench1.rb: fix paramter too. Increase temporary objects. diff --git a/benchmark/gc/gcbench.rb b/benchmark/gc/gcbench.rb new file mode 100644 index 0000000000..5fee2a2bce --- /dev/null +++ b/benchmark/gc/gcbench.rb @@ -0,0 +1,27 @@ + +require 'benchmark' +require 'pp' + +script = File.join(__dir__, ARGV.shift) +script += '.rb' unless FileTest.exist?(script) +raise "#{script} not found" unless FileTest.exist?(script) + +puts "Script: #{script}" + +GC::Profiler.enable +tms = Benchmark.measure{|x| + load script +} +GC::Profiler.report +pp GC.stat + +gc_time = GC::Profiler.total_time + +puts +puts script +puts Benchmark::CAPTION +puts tms +puts "GC total time (sec): #{gc_time}" +puts +puts "Summary #{RUBY_DESCRIPTION}\t#{tms.real}\t#{gc_time}\t#{GC.count}" +puts " (real time in sec, GC time in sec, GC count)" diff --git a/benchmark/gc/hash1.rb b/benchmark/gc/hash1.rb new file mode 100644 index 0000000000..cb030d458d --- /dev/null +++ b/benchmark/gc/hash1.rb @@ -0,0 +1,11 @@ +value = 0.01 +h = {} +n = 50_000 + +1.upto(n){|i| + h["%020d" % i] = "v-#{i}" +} + +(n * 1_000).times{ + '' +} diff --git a/benchmark/gc/hash2.rb b/benchmark/gc/hash2.rb new file mode 100644 index 0000000000..e8c943fb21 --- /dev/null +++ b/benchmark/gc/hash2.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/benchmark/gc/null.rb b/benchmark/gc/null.rb new file mode 100644 index 0000000000..31c18878b5 --- /dev/null +++ b/benchmark/gc/null.rb @@ -0,0 +1 @@ +# null diff --git a/benchmark/gc/rdoc.rb b/benchmark/gc/rdoc.rb new file mode 100644 index 0000000000..14c89f5611 --- /dev/null +++ b/benchmark/gc/rdoc.rb @@ -0,0 +1,13 @@ +require 'rdoc/rdoc' +require 'tmpdir' + +srcdir = File.expand_path('../..', __dir__) + +Dir.mktmpdir('rdocbench-'){|d| + dir = File.join(d, 'rdocbench') + args = %W(--root #{srcdir} --page-dir #{srcdir}/doc --encoding=UTF-8 --no-force-update --all --ri --debug --quiet #{srcdir}) + args << '--op' << dir + + r = RDoc::RDoc.new + r.document args +} diff --git a/common.mk b/common.mk index 83e6ce7599..88043575d0 100644 --- a/common.mk +++ b/common.mk @@ -426,19 +426,13 @@ rdoc-coverage: PHONY main RDOCBENCHOUT=/tmp/rdocbench -gcbench-rdoc: PHONY - @echo Benchmark with Generating RDoc documentation - $(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)" - -gcbench-hash1: PHONY - @echo "Benchmark with hashbench1 (many temporal objects / obj count intensive)" - $(Q) $(XRUBY) "$(srcdir)/tool/gcbench.rb" "$(srcdir)/tool/hashbench1.rb" +GCBENCH_ITEM=null -gcbench-hash2: PHONY - @echo "Benchmark with hashbench2 (increasing hash size / malloc intensive)" - $(Q) $(XRUBY) "$(srcdir)/tool/gcbench.rb" "$(srcdir)/tool/hashbench2.rb" +gcbench: PHONY + $(Q) $(XRUBY) "$(srcdir)/benchmark/gc/gcbench.rb" $(GCBENCH_ITEM) -gcbench-hash: PHONY gcbench-hash1 gcbench-hash2 +gcbench-rdoc: PHONY + $(Q) $(XRUBY) "$(srcdir)/benchmark/gc/gcbench.rb" rdoc nodoc: PHONY diff --git a/tool/gcbench.rb b/tool/gcbench.rb deleted file mode 100644 index ca9f3cd950..0000000000 --- a/tool/gcbench.rb +++ /dev/null @@ -1,22 +0,0 @@ - -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_DESCRIPTION}\t#{tms.real}\t#{gc_time}\t#{GC.count}" -puts " (real time in sec, GC time in sec, GC count)" diff --git a/tool/hashbench1.rb b/tool/hashbench1.rb deleted file mode 100644 index cb030d458d..0000000000 --- a/tool/hashbench1.rb +++ /dev/null @@ -1,11 +0,0 @@ -value = 0.01 -h = {} -n = 50_000 - -1.upto(n){|i| - h["%020d" % i] = "v-#{i}" -} - -(n * 1_000).times{ - '' -} diff --git a/tool/hashbench2.rb b/tool/hashbench2.rb deleted file mode 100644 index e8c943fb21..0000000000 --- a/tool/hashbench2.rb +++ /dev/null @@ -1,7 +0,0 @@ -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 deleted file mode 100644 index a248b9a9b7..0000000000 --- a/tool/rdocbench.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'rdoc/rdoc' -require 'tmpdir' - -Dir.mktmpdir('rdocbench-'){|d| - dir = File.join(d, 'rdocbench') - args = ARGV.dup - args << '--op' << dir - - r = RDoc::RDoc.new - r.document args -} -- cgit v1.2.3