From 7b730a2f1b9be71695c1a01efc1fd05e98757736 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 23 Jun 2010 16:11:07 -0700 Subject: Show GC time and # of runs too --- tools/profile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tools/profile') diff --git a/tools/profile b/tools/profile index f02f1b5057..c86cedcbf4 100755 --- a/tools/profile +++ b/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] -- cgit v1.2.3 From 4883082ff1d3f73666c284e8c4bce4a2a12b36c1 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 24 Jun 2010 01:08:12 -0700 Subject: Support an extra profile printer arg --- tools/profile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tools/profile') diff --git a/tools/profile b/tools/profile index c86cedcbf4..a6e3b41900 100755 --- a/tools/profile +++ b/tools/profile @@ -63,7 +63,9 @@ after = GC.allocated_size usage = (after - before) / 1024.0 if mode - if RubyProf.const_defined?(:CallStackPrinter) + if printer = ARGV.shift + RubyProf.const_get("#{printer.to_s.classify}Printer").new(results).print($stdout) + elsif RubyProf.const_defined?(:CallStackPrinter) File.open("#{File.basename(path, '.rb')}.#{mode}.html", 'w') do |out| RubyProf::CallStackPrinter.new(results).print(out) end -- cgit v1.2.3