mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
55ae2402f4
commit
57bb153456
6 changed files with 67 additions and 21 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
Thu Jun 20 07:30:35 2013 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* 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@atdot.net>
|
||||
|
||||
* tool/rdocbench.rb: add summary.
|
||||
|
|
12
common.mk
12
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
|
||||
|
||||
|
|
24
tool/gcbench.rb
Normal file
24
tool/gcbench.rb
Normal file
|
@ -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}"
|
11
tool/hashbench1.rb
Normal file
11
tool/hashbench1.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
value = 0.01
|
||||
h = {}
|
||||
n = 100_000
|
||||
|
||||
1.upto(n){|i|
|
||||
h["%020d" % i] = value * i
|
||||
}
|
||||
|
||||
(n * 500).times{
|
||||
''
|
||||
}
|
7
tool/hashbench2.rb
Normal file
7
tool/hashbench2.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
value = 0.01
|
||||
h = {}
|
||||
n = 4*(10**6)
|
||||
|
||||
1.upto(n){|i|
|
||||
h["%020d" % i] = value * i
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue