Skip to content

Instantly share code, notes, and snippets.

@danlucraft
Created March 9, 2010 12:35
Show Gist options
  • Save danlucraft/326533 to your computer and use it in GitHub Desktop.
Save danlucraft/326533 to your computer and use it in GitHub Desktop.
$ cat example/test.rb
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require 'jruby-prof'
class Thing
def stuff1
10000.times { 1 + 2; "asdf".length }
end
def length
"asdf".length
end
def stuff4
10000.times { length }
end
end
s = Time.now
JRubyProf.start
thing.stuff1
thing.stuff4
JRubyProf.stop
puts "took #{Time.now - s}s"
JRubyProf.print_graph_text("tracing_example.txt")
$ less tracing_example.txt
%total %self total self children calls Name
----------------------------------------------------------------------------------------------------
100.00% 0.00% 380 0 380 1 #toplevel
172 2 170 1 Thing#stuff1
208 91 117 1 Thing#stuff4
----------------------------------------------------------------------------------------------------
172 2 170 1 Thing#stuff1
208 91 117 1 Thing#stuff4
75.53% 47.37% 287 180 107 2 Fixnum#times
7 7 0 10000 Fixnum#+
10 10 0 10000 String#length
90 89 1 10000 Thing#length
----------------------------------------------------------------------------------------------------
380 0 380 0 #toplevel
54.74% 23.95% 208 91 117 1 Thing#stuff4
117 27 90 1 Fixnum#times
----------------------------------------------------------------------------------------------------
380 0 380 0 #toplevel
45.26% 0.53% 172 2 170 1 Thing#stuff1
170 153 17 1 Fixnum#times
----------------------------------------------------------------------------------------------------
117 27 90 1 Fixnum#times
23.68% 23.42% 90 89 1 10000 Thing#length
1 1 0 10000 String#length
----------------------------------------------------------------------------------------------------
170 153 17 1 Fixnum#times
90 89 1 10000 Thing#length
2.89% 2.89% 11 11 0 20000 String#length
----------------------------------------------------------------------------------------------------
170 153 17 1 Fixnum#times
1.84% 1.84% 7 7 0 10000 Fixnum#+
----------------------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment