From 961fb1bcf28df15c32300dc4e7086d0e4ee555a5 Mon Sep 17 00:00:00 2001 From: rogerdpack Date: Mon, 26 Jul 2010 14:26:47 -0600 Subject: [PATCH 1/4] add weak jruby-prof executable --- Rakefile | 4 +++- bin/jruby-prof | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 bin/jruby-prof diff --git a/Rakefile b/Rakefile index 73fb004..2f1b2b6 100644 --- a/Rakefile +++ b/Rakefile @@ -15,8 +15,10 @@ spec = Gem::Specification.new do |s| Dir.glob("{templates/**/*}") + Dir.glob("{examples/**/*}") + Dir.glob("{src}/**/*") + - Dir.glob("{test}/**/*") + Dir.glob("{test}/**/*") + + Dir.glob("{bin}/*") s.require_paths = ["lib"] + s.executables = ["jruby-prof"] end Rake::GemPackageTask.new(spec) do |pkg| diff --git a/bin/jruby-prof b/bin/jruby-prof new file mode 100644 index 0000000..15e1838 --- /dev/null +++ b/bin/jruby-prof @@ -0,0 +1,20 @@ + require 'rubygems' + require 'jruby-prof' + + if ARGV.detect{|arg| arg == '-h' || arg == '--help'} + puts 'syntax: script_name arg1 arg2 arg3 (writes several outputs to profile/*)' + exit 1 + end + + ruby_script = ARGV.shift + result = JRubyProf.profile { + require ruby_script + } + + require 'fileutils' + FileUtils.mkdir_p "profile" + JRubyProf.print_flat_text(result, "profile/flat.txt") + JRubyProf.print_graph_text(result, "profile/graph.txt") + JRubyProf.print_graph_html(result, "profile/graph.html") + JRubyProf.print_call_tree(result, "profile/call_tree.txt") + JRubyProf.print_tree_html(result, "profile/call_tree.html") \ No newline at end of file From 90be816f8669df6054ba83ccf49398becbd247f7 Mon Sep 17 00:00:00 2001 From: rogerdpack Date: Mon, 2 Aug 2010 05:34:42 -0600 Subject: [PATCH 2/4] write output relative to starting dir --- bin/jruby-prof | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/bin/jruby-prof b/bin/jruby-prof index 15e1838..d3fe7f9 100644 --- a/bin/jruby-prof +++ b/bin/jruby-prof @@ -1,8 +1,9 @@ require 'rubygems' require 'jruby-prof' + original_dir = Dir.pwd if ARGV.detect{|arg| arg == '-h' || arg == '--help'} - puts 'syntax: script_name arg1 arg2 arg3 (writes several outputs to profile/*)' + puts 'syntax: script_name arg1 arg2 arg3 (writes the several outputs available to profile/*)' exit 1 end @@ -11,10 +12,12 @@ require ruby_script } - require 'fileutils' - FileUtils.mkdir_p "profile" - JRubyProf.print_flat_text(result, "profile/flat.txt") - JRubyProf.print_graph_text(result, "profile/graph.txt") - JRubyProf.print_graph_html(result, "profile/graph.html") - JRubyProf.print_call_tree(result, "profile/call_tree.txt") - JRubyProf.print_tree_html(result, "profile/call_tree.html") \ No newline at end of file + Dir.chdir(original_dir) do + require 'fileutils' + FileUtils.mkdir_p "profile" + JRubyProf.print_flat_text(result, "profile/flat.txt") + JRubyProf.print_graph_text(result, "profile/graph.txt") + JRubyProf.print_graph_html(result, "profile/graph.html") + JRubyProf.print_call_tree(result, "profile/call_tree.txt") + JRubyProf.print_tree_html(result, "profile/call_tree.html") + end \ No newline at end of file From c9b1f7bc1577e9c5d111cc8f20307f966e446fc8 Mon Sep 17 00:00:00 2001 From: rogerdpack Date: Mon, 2 Aug 2010 05:39:02 -0600 Subject: [PATCH 3/4] tweak README --- README | 7 +++++++ bin/jruby-prof | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README b/README index 4084f77..7a87886 100644 --- a/README +++ b/README @@ -40,6 +40,13 @@ run your script with the debug flag on: $ jruby --debug my_script.rb + +Or you can use its gem script: + + $ jruby --debug -S jruby-prof scriptname.rb + +Which will profile the entire script, create a local directory named "profile" and output one copy of each graph type there. + LICENSE ------- diff --git a/bin/jruby-prof b/bin/jruby-prof index d3fe7f9..81cde92 100644 --- a/bin/jruby-prof +++ b/bin/jruby-prof @@ -3,7 +3,7 @@ original_dir = Dir.pwd if ARGV.detect{|arg| arg == '-h' || arg == '--help'} - puts 'syntax: script_name arg1 arg2 arg3 (writes the several outputs available to profile/*)' + puts 'syntax: jruby --debug -S jruby-prof script_name arg1 arg2 arg3 (writes the several outputs available to profile/*)' exit 1 end From 22f0365061730c630dbb5fbb2410d901f3d49eae Mon Sep 17 00:00:00 2001 From: rogerdpack Date: Mon, 6 Dec 2010 06:50:29 -0700 Subject: [PATCH 4/4] fork --- Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 2f1b2b6..e5f7f39 100644 --- a/Rakefile +++ b/Rakefile @@ -3,8 +3,8 @@ require "rake/gempackagetask" require "rake/rdoctask" spec = Gem::Specification.new do |s| - s.name = "jruby-prof" - s.version = "0.1.0" + s.name = "rdp-jruby-prof" + s.version = "0.1.0.1" s.summary = "A Ruby level profiler for JRuby" s.author = "Daniel Lucraft" s.email = "dan@fluentradical.com"