2013-06-19 22:33:02 +00:00
|
|
|
|
|
|
|
require 'benchmark'
|
|
|
|
require 'pp'
|
|
|
|
|
2013-06-20 08:25:16 +00:00
|
|
|
script = File.join(File.dirname(__FILE__), ARGV.shift)
|
2013-06-20 06:18:09 +00:00
|
|
|
script += '.rb' unless FileTest.exist?(script)
|
|
|
|
raise "#{script} not found" unless FileTest.exist?(script)
|
|
|
|
|
|
|
|
puts "Script: #{script}"
|
2013-06-19 22:33:02 +00:00
|
|
|
|
|
|
|
GC::Profiler.enable
|
|
|
|
tms = Benchmark.measure{|x|
|
|
|
|
load script
|
|
|
|
}
|
2013-06-20 09:31:51 +00:00
|
|
|
gc_time = GC::Profiler.total_time
|
|
|
|
GC::Profiler.report if RUBY_VERSION >= '2.0.0' # before 1.9.3, report() may run infinite loop
|
2013-06-20 09:00:41 +00:00
|
|
|
GC::Profiler.disable
|
2013-06-19 22:33:02 +00:00
|
|
|
pp GC.stat
|
|
|
|
|
2013-06-21 08:57:18 +00:00
|
|
|
desc = "#{RUBY_VERSION}#{RUBY_PATCHLEVEL >= 0 ? "p#{RUBY_PATCHLEVEL}" : "dev"}"
|
|
|
|
name = File.basename(script, '.rb')
|
|
|
|
|
2013-06-19 22:33:02 +00:00
|
|
|
puts
|
2013-06-20 06:18:09 +00:00
|
|
|
puts script
|
2013-06-19 22:33:02 +00:00
|
|
|
puts Benchmark::CAPTION
|
|
|
|
puts tms
|
|
|
|
puts "GC total time (sec): #{gc_time}"
|
|
|
|
puts
|
2013-06-21 08:57:18 +00:00
|
|
|
puts "Summary of #{name} on #{desc}\t#{tms.real}\t#{gc_time}\t#{GC.count}"
|
2013-06-19 23:15:56 +00:00
|
|
|
puts " (real time in sec, GC time in sec, GC count)"
|