1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/benchmark/gc/gcbench.rb
ko1 99b10ff471 * 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
2013-06-20 06:18:09 +00:00

27 lines
567 B
Ruby

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)"