aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-05-21 13:21:29 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-05-21 13:21:29 +0000
commit48bb9bb0ad5a090a9b8d6ad1deeadd9b1ae10d8b (patch)
tree0736390aed0db0910b2add1899e74fb262360754 /railties
parentca873648eab40d6ceb221c4d359c1f177fba0493 (diff)
downloadrails-48bb9bb0ad5a090a9b8d6ad1deeadd9b1ae10d8b.tar.gz
rails-48bb9bb0ad5a090a9b8d6ad1deeadd9b1ae10d8b.tar.bz2
rails-48bb9bb0ad5a090a9b8d6ad1deeadd9b1ae10d8b.zip
Missing file
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1342 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rubyprof_ext.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/railties/lib/rubyprof_ext.rb b/railties/lib/rubyprof_ext.rb
new file mode 100644
index 0000000000..0a1f4a5504
--- /dev/null
+++ b/railties/lib/rubyprof_ext.rb
@@ -0,0 +1,35 @@
+require 'prof'
+
+module Prof
+ # Adapted from Shugo Maeda's unprof.rb
+ def self.print_profile(results, io = $stderr)
+ total = results.detect { |i|
+ i.method_class.nil? && i.method_id == :"#toplevel"
+ }.total_time
+ total = 0.001 if total < 0.001
+
+ io.puts " %% cumulative self self total"
+ io.puts " time seconds seconds calls ms/call ms/call name"
+
+ sum = 0.0
+ for r in results
+ sum += r.self_time
+
+ name = if r.method_class.nil?
+ r.method_id.to_s
+ elsif r.method_class.is_a?(Class)
+ "#{r.method_class}##{r.method_id}"
+ else
+ "#{r.method_class}.#{r.method_id}"
+ end
+ io.printf "%6.2f %8.3f %8.3f %8d %8.2f %8.2f %s\n",
+ r.self_time / total * 100,
+ sum,
+ r.self_time,
+ r.count,
+ r.self_time * 1000 / r.count,
+ r.total_time * 1000 / r.count,
+ name
+ end
+ end
+end