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/Rakefile b/Rakefile index 73fb004..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" @@ -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..81cde92 --- /dev/null +++ b/bin/jruby-prof @@ -0,0 +1,23 @@ + require 'rubygems' + require 'jruby-prof' + original_dir = Dir.pwd + + if ARGV.detect{|arg| arg == '-h' || arg == '--help'} + puts 'syntax: jruby --debug -S jruby-prof script_name arg1 arg2 arg3 (writes the several outputs available to profile/*)' + exit 1 + end + + ruby_script = ARGV.shift + result = JRubyProf.profile { + require ruby_script + } + + 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