ruby/benchmark/gc/gcbench.rb

29 строки
603 B
Ruby
Исходник Обычный вид История

require 'benchmark'
require 'pp'
script = File.join(File.dirname(__FILE__), 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.disable
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)"