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