From dd2c9eb72df6ea6adacf6158ed532fe216e8e847 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sun, 12 Sep 2010 14:11:05 -0700 Subject: [PATCH] Add a --profile option to the compass CLI --- Gemfile | 1 + bin/compass | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 491d5285..9fc9776c 100644 --- a/Gemfile +++ b/Gemfile @@ -11,3 +11,4 @@ gem "rcov" gem "rubyzip" gem "livereload" gem "chunky_png" +gem "ruby-prof" diff --git a/bin/compass b/bin/compass index f816f3e9..094bd700 100755 --- a/bin/compass +++ b/bin/compass @@ -21,6 +21,21 @@ fallback_load_path(File.join(File.dirname(__FILE__), '..', 'lib')) do require 'compass/exec' end +runner = Proc.new do + command_line_class = Compass::Exec::Helpers.select_appropriate_command_line_ui(ARGV) + command_line_class.new(ARGV).run! +end -command_line_class = Compass::Exec::Helpers.select_appropriate_command_line_ui(ARGV) -exit command_line_class.new(ARGV).run! +if ARGV.delete("--profile") + require 'ruby-prof' + RubyProf.start + exit_code = runner.call + result = RubyProf.stop + + # Print a flat profile to text + printer = RubyProf::FlatPrinter.new(result) + printer.print(STDERR, 0) + exit exit_code +else + exit runner.call +end