Skip to content
Browse files

Show GC time and # of runs too

  • Loading branch information...
1 parent 69abbe8 commit 7b730a2f1b9be71695c1a01efc1fd05e98757736 @jeremy jeremy committed Jun 23, 2010
Showing with 3 additions and 1 deletion.
  1. +3 −1 tools/profile
View
4 tools/profile
@@ -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]

0 comments on commit 7b730a2

Please sign in to comment.
Something went wrong with that request. Please try again.