Show GC time and # of runs too

This commit is contained in:
Jeremy Kemper 2010-06-23 16:11:07 -07:00
parent 69abbe8934
commit 7b730a2f1b
1 changed files with 3 additions and 1 deletions

View File

@ -39,6 +39,7 @@ end
GC.start
before = GC.allocated_size
before_gctime, before_gcruns = GC.time, GC.collections
before_rss = `ps -o rss= -p #{Process.pid}`.to_i
before_live_objects = ObjectSpace.live_objects
@ -54,6 +55,7 @@ end
elapsed = Benchmark.realtime { require path }
results = RubyProf.stop if mode
after_gctime, after_gcruns = GC.time, GC.collections
GC.start
after_live_objects = ObjectSpace.live_objects
after_rss = `ps -o rss= -p #{Process.pid}`.to_i
@ -79,4 +81,4 @@ RequireProfiler.stats.each do |file, depth, sec, bytes, objects|
puts "#{' ' * (42 + depth)}#{file}"
end
end
puts "%10.2f KB %10d obj %8.1f ms %d KB RSS" % [usage, after_live_objects - before_live_objects, elapsed * 1000, after_rss - before_rss]
puts "%10.2f KB %10d obj %8.1f ms %d KB RSS %8.1f ms GC time %d GC runs" % [usage, after_live_objects - before_live_objects, elapsed * 1000, after_rss - before_rss, (after_gctime - before_gctime) / 1000.0, after_gcruns - before_gcruns]