ruby-prof 0.15.5 → 0.15.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +4 -1
- data/doc/RubyProf.html +5 -6
- data/doc/RubyProf/CallInfo.html +259 -11
- data/doc/RubyProf/CallInfoPrinter.html +2 -2
- data/doc/RubyProf/CallInfoVisitor.html +7 -9
- data/doc/RubyProf/DotPrinter.html +2 -2
- data/doc/RubyProf/GraphHtmlPrinter.html +62 -58
- data/doc/RubyProf/MethodInfo.html +230 -30
- data/doc/RubyProf/Profile.html +2 -53
- data/doc/RubyProf/Thread.html +108 -4
- data/doc/created.rid +11 -11
- data/doc/js/search_index.js +1 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/table_of_contents.html +120 -50
- data/ext/ruby_prof/rp_call_info.h +1 -1
- data/lib/ruby-prof/call_info.rb +54 -2
- data/lib/ruby-prof/call_info_visitor.rb +10 -12
- data/lib/ruby-prof/method_info.rb +31 -17
- data/lib/ruby-prof/printers/call_info_printer.rb +2 -2
- data/lib/ruby-prof/printers/dot_printer.rb +27 -27
- data/lib/ruby-prof/printers/graph_html_printer.rb +62 -58
- data/lib/ruby-prof/printers/graph_printer.rb +4 -3
- data/lib/ruby-prof/profile.rb +1 -22
- data/lib/ruby-prof/thread.rb +15 -3
- data/lib/ruby-prof/version.rb +1 -1
- data/test/call_info_visitor_test.rb +1 -1
- metadata +1 -1
@@ -48,12 +48,11 @@ module RubyProf
|
|
48
48
|
# Print each method in total time order
|
49
49
|
methods.reverse_each do |method|
|
50
50
|
total_percentage = (method.total_time/total_time) * 100
|
51
|
-
self_percentage = (method.self_time/total_time) * 100
|
52
|
-
|
53
51
|
next if total_percentage < min_percent
|
54
52
|
|
55
|
-
|
53
|
+
self_percentage = (method.self_time/total_time) * 100
|
56
54
|
|
55
|
+
@output << "-" * 80 << "\n"
|
57
56
|
print_parents(thread, method)
|
58
57
|
|
59
58
|
# 1 is for % sign
|
@@ -71,7 +70,9 @@ module RubyProf
|
|
71
70
|
end
|
72
71
|
@output << "\n"
|
73
72
|
|
73
|
+
method.recalc_recursion unless method.non_recursive?
|
74
74
|
print_children(method)
|
75
|
+
thread.recalc_recursion unless method.non_recursive?
|
75
76
|
end
|
76
77
|
end
|
77
78
|
|
data/lib/ruby-prof/profile.rb
CHANGED
@@ -8,28 +8,7 @@ module RubyProf
|
|
8
8
|
# a hook to do any necessary post-processing on the call graph.
|
9
9
|
def post_process
|
10
10
|
self.threads.each do |thread|
|
11
|
-
detect_recursion
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# This method detect recursive calls in the call graph.
|
16
|
-
def detect_recursion(thread)
|
17
|
-
visited_methods = Hash.new do |hash, key|
|
18
|
-
hash[key] = 0
|
19
|
-
end
|
20
|
-
|
21
|
-
visitor = CallInfoVisitor.new(thread)
|
22
|
-
visitor.visit do |call_info, event|
|
23
|
-
case event
|
24
|
-
when :enter
|
25
|
-
if (visited_methods[call_info.target] += 1) > 1
|
26
|
-
call_info.recursive = true
|
27
|
-
end
|
28
|
-
when :exit
|
29
|
-
if (visited_methods[call_info.target] -= 1) == 0
|
30
|
-
visited_methods.delete(call_info.target)
|
31
|
-
end
|
32
|
-
end
|
11
|
+
thread.detect_recursion
|
33
12
|
end
|
34
13
|
end
|
35
14
|
|
data/lib/ruby-prof/thread.rb
CHANGED
@@ -2,12 +2,24 @@ module RubyProf
|
|
2
2
|
class Thread
|
3
3
|
def top_methods
|
4
4
|
self.methods.select do |method_info|
|
5
|
-
method_info.call_infos.detect
|
6
|
-
call_info.parent.nil?
|
7
|
-
end
|
5
|
+
method_info.call_infos.detect(&:root?)
|
8
6
|
end
|
9
7
|
end
|
10
8
|
|
9
|
+
def top_call_infos
|
10
|
+
top_methods.map(&:call_infos).flatten.select(&:root?)
|
11
|
+
end
|
12
|
+
|
13
|
+
# This method detect recursive calls in the call tree of a given thread
|
14
|
+
# It should be called only once for each thread
|
15
|
+
def detect_recursion
|
16
|
+
top_call_infos.each(&:detect_recursion)
|
17
|
+
end
|
18
|
+
|
19
|
+
def recalc_recursion
|
20
|
+
top_call_infos.each(&:recalc_recursion)
|
21
|
+
end
|
22
|
+
|
11
23
|
def total_time
|
12
24
|
self.top_methods.inject(0) do |sum, method_info|
|
13
25
|
method_info.call_infos.each do |call_info|
|
data/lib/ruby-prof/version.rb
CHANGED