Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
From: Rich Lane <rlane@club.cc.cmu.edu>
To: sup-devel@rubyforge.org
Subject: [sup-devel] [PATCH] enable ruby-prof with SUP_PROFILE environment variable
Date: Sat, 23 Jan 2010 19:16:00 -0800	[thread overview]
Message-ID: <1264302960-17337-1-git-send-email-rlane@club.cc.cmu.edu> (raw)

If SUP_PROFILE is set, it's used as the filename to dump profiling output
which you can use kcachegrind to inspect.
---
 bin/sup |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/bin/sup b/bin/sup
index 7824aca..f7c4af7 100755
--- a/bin/sup
+++ b/bin/sup
@@ -14,6 +14,11 @@ require 'fileutils'
 require 'trollop'
 require "sup"; Redwood::check_library_version_against "git"
 
+if ENV['SUP_PROFILE']
+  require 'ruby-prof'
+  RubyProf.start
+end
+
 if no_ncursesw
   debug "No 'ncursesw' gem detected. Install it for wide character support."
 end
@@ -379,6 +384,11 @@ ensure
   end
 
   Index.unlock
+
+  if (fn = ENV['SUP_PROFILE'])
+    result = RubyProf.stop
+    File.open(fn, 'w') { |io| RubyProf::CallTreePrinter.new(result).print(io) }
+  end
 end
 
 unless Redwood::exceptions.empty?
-- 
1.6.3.3

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


             reply	other threads:[~2010-01-24  3:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-24  3:16 Rich Lane [this message]
2010-01-24  3:22 ` Anthony Martinez
2010-02-27  7:45 ` Rich Lane

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1264302960-17337-1-git-send-email-rlane@club.cc.cmu.edu \
    --to=rlane@club.cc.cmu.edu \
    --cc=sup-devel@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox