ruby-prof 0.15.8 → 0.15.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +5 -0
  3. data/README.rdoc +187 -185
  4. data/doc/LICENSE.html +114 -0
  5. data/doc/README_rdoc.html +544 -0
  6. data/doc/Rack.html +95 -0
  7. data/doc/Rack/RubyProf.html +223 -0
  8. data/doc/RubyProf.html +961 -0
  9. data/doc/RubyProf/AbstractPrinter.html +546 -0
  10. data/doc/RubyProf/AggregateCallInfo.html +551 -0
  11. data/doc/RubyProf/CallInfo.html +639 -0
  12. data/doc/RubyProf/CallInfoPrinter.html +120 -0
  13. data/doc/RubyProf/CallInfoVisitor.html +198 -0
  14. data/doc/RubyProf/CallStackPrinter.html +1121 -0
  15. data/doc/RubyProf/CallTreePrinter.html +359 -0
  16. data/doc/RubyProf/Cmd.html +631 -0
  17. data/doc/RubyProf/DotPrinter.html +257 -0
  18. data/doc/RubyProf/FlatPrinter.html +163 -0
  19. data/doc/RubyProf/FlatPrinterWithLineNumbers.html +208 -0
  20. data/doc/RubyProf/GraphHtmlPrinter.html +552 -0
  21. data/doc/RubyProf/GraphPrinter.html +139 -0
  22. data/doc/RubyProf/MethodInfo.html +745 -0
  23. data/doc/RubyProf/MultiPrinter.html +358 -0
  24. data/doc/RubyProf/Profile.html +713 -0
  25. data/doc/RubyProf/ProfileTask.html +490 -0
  26. data/doc/RubyProf/Thread.html +268 -0
  27. data/doc/created.rid +13 -13
  28. data/doc/examples/flat_txt.html +138 -0
  29. data/doc/examples/graph_html.html +909 -0
  30. data/doc/examples/graph_txt.html +247 -0
  31. data/doc/images/add.png +0 -0
  32. data/doc/images/arrow_up.png +0 -0
  33. data/doc/images/brick.png +0 -0
  34. data/doc/images/brick_link.png +0 -0
  35. data/doc/images/bug.png +0 -0
  36. data/doc/images/bullet_black.png +0 -0
  37. data/doc/images/bullet_toggle_minus.png +0 -0
  38. data/doc/images/bullet_toggle_plus.png +0 -0
  39. data/doc/images/date.png +0 -0
  40. data/doc/images/delete.png +0 -0
  41. data/doc/images/find.png +0 -0
  42. data/doc/images/macFFBgHack.png +0 -0
  43. data/doc/images/package.png +0 -0
  44. data/doc/images/page_green.png +0 -0
  45. data/doc/images/page_white_text.png +0 -0
  46. data/doc/images/page_white_width.png +0 -0
  47. data/doc/images/plugin.png +0 -0
  48. data/doc/images/ruby.png +0 -0
  49. data/doc/images/tag_blue.png +0 -0
  50. data/doc/images/tag_green.png +0 -0
  51. data/doc/images/transparent.png +0 -0
  52. data/doc/images/wrench.png +0 -0
  53. data/doc/images/wrench_orange.png +0 -0
  54. data/doc/images/zoom.png +0 -0
  55. data/doc/index.html +571 -0
  56. data/doc/js/navigation.js.gz +0 -0
  57. data/doc/js/search_index.js +1 -1
  58. data/doc/js/search_index.js.gz +0 -0
  59. data/doc/js/searcher.js.gz +0 -0
  60. data/doc/table_of_contents.html +893 -0
  61. data/examples/flat.txt +50 -55
  62. data/examples/graph.html +823 -823
  63. data/examples/graph.txt +139 -170
  64. data/ext/ruby_prof/extconf.rb +6 -1
  65. data/lib/ruby-prof/aggregate_call_info.rb +17 -11
  66. data/lib/ruby-prof/call_info.rb +2 -17
  67. data/lib/ruby-prof/method_info.rb +6 -22
  68. data/lib/ruby-prof/printers/graph_html_printer.rb +0 -2
  69. data/lib/ruby-prof/printers/graph_printer.rb +4 -6
  70. data/lib/ruby-prof/rack.rb +7 -0
  71. data/lib/ruby-prof/thread.rb +0 -4
  72. data/lib/ruby-prof/version.rb +1 -1
  73. data/ruby-prof.gemspec +1 -1
  74. data/test/basic_test.rb +26 -26
  75. data/test/issue137_test.rb +63 -0
  76. data/test/measure_allocations_test.rb +4 -3
  77. data/test/measure_cpu_time_test.rb +6 -6
  78. data/test/measure_process_time_test.rb +8 -8
  79. data/test/pause_resume_test.rb +9 -9
  80. data/test/printers_test.rb +1 -1
  81. data/test/printing_recursive_graph_test.rb +127 -0
  82. data/test/rack_test.rb +49 -1
  83. data/test/recursive_test.rb +41 -37
  84. data/test/test_helper.rb +93 -0
  85. metadata +59 -5
@@ -1,170 +1,139 @@
1
- = Graph Profiles
2
-
3
- Graph profiles show how long each method runs, which methods call it
4
- and which methods it calls.
5
-
6
- As an example, here is the output from running printers_test.rb:
7
-
8
-
9
- Thread ID: 21277412
10
- %total %self total self children calls Name
11
- --------------------------------------------------------------------------------
12
- 100.00% 0.00% 8.77 0.00 8.77 1 #toplevel
13
- 8.77 0.00 8.77 1/1 Object#run_primes
14
- --------------------------------------------------------------------------------
15
- 8.77 0.00 8.77 1/1 #toplevel
16
- 100.00% 0.00% 8.77 0.00 8.77 1 Object#run_primes
17
- 0.02 0.00 0.02 1/1 Object#make_random_array
18
- 2.09 0.00 2.09 1/1 Object#find_largest
19
- 6.66 0.00 6.66 1/1 Object#find_primes
20
- --------------------------------------------------------------------------------
21
- 6.63 4.06 2.56 500/501 Object#is_prime
22
- 2.09 0.00 2.09 1/501 Object#find_largest
23
- 99.48% 46.34% 8.72 4.06 4.66 501 Integer#upto
24
- 0.00 0.00 0.00 61/61 Array#[]
25
- 0.00 0.00 0.00 61/61 Fixnum#>
26
- 2.09 2.09 0.00 61/61 Kernel.sleep
27
- 1.24 1.24 0.00 250862/250862 Fixnum#==
28
- 1.33 1.33 0.00 250862/250862 Fixnum#%
29
- --------------------------------------------------------------------------------
30
- 6.66 0.01 6.64 1/1 Object#find_primes
31
- 75.93% 0.17% 6.66 0.01 6.64 1 Array#select
32
- 6.64 0.01 6.63 500/500 Object#is_prime
33
- --------------------------------------------------------------------------------
34
- 6.66 0.00 6.66 1/1 Object#run_primes
35
- 75.93% 0.00% 6.66 0.00 6.66 1 Object#find_primes
36
- 6.66 0.01 6.64 1/1 Array#select
37
- --------------------------------------------------------------------------------
38
- 6.64 0.01 6.63 500/500 Array#select
39
- 75.76% 0.17% 6.64 0.01 6.63 500 Object#is_prime
40
- 0.00 0.00 0.00 500/501 Fixnum#-
41
- 6.63 4.06 2.56 500/501 Integer#upto
42
- --------------------------------------------------------------------------------
43
- 2.09 0.00 2.09 1/1 Object#run_primes
44
- 23.89% 0.00% 2.09 0.00 2.09 1 Object#find_largest
45
- 0.00 0.00 0.00 1/501 Fixnum#-
46
- 2.09 0.00 2.09 1/501 Integer#upto
47
- 0.00 0.00 0.00 1/1 Array#first
48
- 0.00 0.00 0.00 1/1 Array#length
49
- --------------------------------------------------------------------------------
50
- 2.09 2.09 0.00 61/61 Integer#upto
51
- 23.89% 23.89% 2.09 2.09 0.00 61 Kernel.sleep
52
- --------------------------------------------------------------------------------
53
- 1.33 1.33 0.00 250862/250862 Integer#upto
54
- 15.12% 15.12% 1.33 1.33 0.00 250862 Fixnum#%
55
- --------------------------------------------------------------------------------
56
- 1.24 1.24 0.00 250862/250862 Integer#upto
57
- 14.13% 14.13% 1.24 1.24 0.00 250862 Fixnum#==
58
- --------------------------------------------------------------------------------
59
- 0.02 0.00 0.02 1/1 Object#run_primes
60
- 0.18% 0.00% 0.02 0.00 0.02 1 Object#make_random_array
61
- 0.02 0.02 0.00 1/1 Array#each_index
62
- 0.00 0.00 0.00 1/1 Class#new
63
- --------------------------------------------------------------------------------
64
- 0.02 0.02 0.00 1/1 Object#make_random_array
65
- 0.18% 0.18% 0.02 0.02 0.00 1 Array#each_index
66
- 0.00 0.00 0.00 500/500 Kernel.rand
67
- 0.00 0.00 0.00 500/500 Array#[]=
68
- --------------------------------------------------------------------------------
69
- 0.00 0.00 0.00 500/501 Object#is_prime
70
- 0.00 0.00 0.00 1/501 Object#find_largest
71
- 0.00% 0.00% 0.00 0.00 0.00 501 Fixnum#-
72
- --------------------------------------------------------------------------------
73
- 0.00 0.00 0.00 1/1 Kernel.rand
74
- 0.00% 0.00% 0.00 0.00 0.00 1 Integer#to_int
75
- --------------------------------------------------------------------------------
76
- 0.00 0.00 0.00 1/1 Object#find_largest
77
- 0.00% 0.00% 0.00 0.00 0.00 1 Array#first
78
- --------------------------------------------------------------------------------
79
- 0.00 0.00 0.00 1/1 Class#new
80
- 0.00% 0.00% 0.00 0.00 0.00 1 Array#initialize
81
- --------------------------------------------------------------------------------
82
- 0.00 0.00 0.00 1/1 Object#find_largest
83
- 0.00% 0.00% 0.00 0.00 0.00 1 Array#length
84
- --------------------------------------------------------------------------------
85
- 0.00 0.00 0.00 1/1 Object#make_random_array
86
- 0.00% 0.00% 0.00 0.00 0.00 1 Class#new
87
- 0.00 0.00 0.00 1/1 Array#initialize
88
- --------------------------------------------------------------------------------
89
- 0.00 0.00 0.00 61/61 Integer#upto
90
- 0.00% 0.00% 0.00 0.00 0.00 61 Fixnum#>
91
- --------------------------------------------------------------------------------
92
- 0.00 0.00 0.00 61/61 Integer#upto
93
- 0.00% 0.00% 0.00 0.00 0.00 61 Array#[]
94
- --------------------------------------------------------------------------------
95
- 0.00 0.00 0.00 500/500 Array#each_index
96
- 0.00% 0.00% 0.00 0.00 0.00 500 Array#[]=
97
- --------------------------------------------------------------------------------
98
- 0.00 0.00 0.00 500/500 Array#each_index
99
- 0.00% 0.00% 0.00 0.00 0.00 500 Kernel.rand
100
- 0.00 0.00 0.00 1/1 Integer#to_int
101
-
102
-
103
-
104
- == Overview
105
- Dashed lines divide the report into entries, with one entry
106
- per method. Entries are sorted by total time which is the
107
- time spent in the method plus its children.
108
-
109
- Each entry has a primary line demarked by values in the
110
- %total and %self columns. The primary line represents
111
- the method being profiled. Lines above it are the methods
112
- that called this method (parents) while the lines below it
113
- are the methods it called (children).
114
-
115
- All values are in seconds. For the primary line, the columns represent:
116
-
117
- %total - The percentage of time spent in this method and its children
118
- %self - The percentage of time spent in this method
119
- total - The time spent in this method and its children.
120
- self - The time spent in this method.
121
- children - The time spent in this method's children.
122
- calls - The number of times this method was called.
123
- name - The name of the method.
124
-
125
- The interpretation of method names is:
126
- * #toplevel - The root method that calls all other methods
127
- * MyObject#test - An instance method "test" of the class "MyObject"
128
- * <Object:MyObject>#test - The <> characters indicate a singleton method on a singleton class.
129
-
130
- For example, we see that 99.48% of the time was spent in Integer#upto and its children.
131
- Of that time, 4.06 seconds was spent in Integer#upto itself and 4.66 in its children.
132
- Overall, Integer#upto was called 501 times.
133
-
134
- == Parents
135
- In each entry, the lines above the primary line are the methods that
136
- called the current method. If the current method is a root method then
137
- no parents are shown.
138
-
139
-
140
- For parent lines, the columns represent:
141
-
142
- total - The time spent in the current method and it children on behalf of the parent method.
143
- self - The time spent in this method on behalf of the parent method.
144
- children - The time spent in this method's children on behalf of the parent.
145
- calls - The number of times the parent method called this child
146
-
147
- Looking at Integer#upto again, we see that it was called 500 times from Object#is_prime
148
- and 1 time from find_largest. Of the 8.72 total seconds spent in Integer#upto, 6.63
149
- were done for Object#is_prime and 2.09 for Object#find_largest.
150
-
151
-
152
- == Children
153
- In each entry, the lines below the primary line are the methods that
154
- the current method called. If the current method is a leaf method then
155
- no children are shown.
156
-
157
- For children lines, the columns represent:
158
-
159
- total - The time spent in the child, and its children, on behalf of the current method
160
- self - The time spent in the child on behalf of the current method.
161
- children - The time spent in the child's children (ie, granchildren) in behalf of the current method
162
- calls - The number of times the child method was called by the current method.
163
-
164
- Taking our example of Integer#upto, we see that it called five other methods - Array#[],
165
- Fixnum#>, Kernel.sleep, Fixnum#= and Fixnum#%. Looking at Kernel.sleep, we see that
166
- its spent 2.09 seconds working for Integer#upto and its children spent 0 time working for
167
- Integer#upto. To see the overall time Kernel.sleep took we would have to look up its entry
168
- in the graph table.
169
-
170
-
1
+ = Graph Profiles
2
+
3
+ Graph profiles show how long each method runs, which methods call it and which
4
+ methods it calls.
5
+
6
+ As an example, here is the output from running printers_test.rb:
7
+
8
+ Measure Mode: wall_time
9
+ Thread ID: 70310439543100
10
+ Fiber ID: 70310456289620
11
+ Total Time: 0.05264616012573242
12
+ Sort by: total_time
13
+
14
+ %total %self total self wait child calls name
15
+ --------------------------------------------------------------------------------
16
+ 100.00% 0.01% 0.053 0.000 0.000 0.053 1 PrintersTest#setup
17
+ 0.053 0.000 0.000 0.053 1/1 Object#run_primes
18
+ --------------------------------------------------------------------------------
19
+ 0.053 0.000 0.000 0.053 1/1 PrintersTest#setup
20
+ 99.99% 0.01% 0.053 0.000 0.000 0.053 1 Object#run_primes
21
+ 0.052 0.000 0.000 0.052 1/1 Object#find_primes
22
+ 0.001 0.000 0.000 0.001 1/1 Object#make_random_array
23
+ 0.000 0.000 0.000 0.000 1/1 Object#find_largest
24
+ --------------------------------------------------------------------------------
25
+ 0.052 0.000 0.000 0.052 1/1 Object#run_primes
26
+ 98.35% 0.00% 0.052 0.000 0.000 0.052 1 Object#find_primes
27
+ 0.052 0.000 0.000 0.051 1/1 Array#select
28
+ --------------------------------------------------------------------------------
29
+ 0.052 0.000 0.000 0.051 1/1 Object#find_primes
30
+ 98.34% 0.61% 0.052 0.000 0.000 0.051 1 Array#select
31
+ 0.051 0.000 0.000 0.051 1000/1000 Object#is_prime
32
+ --------------------------------------------------------------------------------
33
+ 0.051 0.000 0.000 0.051 1000/1000 Array#select
34
+ 97.74% 0.93% 0.051 0.000 0.000 0.051 1000 Object#is_prime
35
+ 0.051 0.051 0.000 0.000 1000/1001 Integer#upto
36
+ --------------------------------------------------------------------------------
37
+ 0.000 0.000 0.000 0.000 1/1001 Object#find_largest
38
+ 0.051 0.051 0.000 0.000 1000/1001 Object#is_prime
39
+ 96.91% 96.91% 0.051 0.051 0.000 0.000 1001 Integer#upto
40
+ --------------------------------------------------------------------------------
41
+ 0.001 0.000 0.000 0.001 1/1 Object#run_primes
42
+ 1.51% 0.00% 0.001 0.000 0.000 0.001 1 Object#make_random_array
43
+ 0.001 0.000 0.000 0.000 1/1 Array#each_index
44
+ 0.000 0.000 0.000 0.000 1/1 Class#new
45
+ --------------------------------------------------------------------------------
46
+ 0.001 0.000 0.000 0.000 1/1 Object#make_random_array
47
+ 1.50% 0.56% 0.001 0.000 0.000 0.000 1 Array#each_index
48
+ 0.000 0.000 0.000 0.000 1000/1000 Kernel#rand
49
+ --------------------------------------------------------------------------------
50
+ 0.000 0.000 0.000 0.000 1000/1000 Array#each_index
51
+ 0.94% 0.72% 0.000 0.000 0.000 0.000 1000 Kernel#rand
52
+ 0.000 0.000 0.000 0.000 1000/1000 Kernel#respond_to_missing?
53
+ --------------------------------------------------------------------------------
54
+ 0.000 0.000 0.000 0.000 1000/1000 Kernel#rand
55
+ 0.22% 0.22% 0.000 0.000 0.000 0.000 1000 Kernel#respond_to_missing?
56
+ --------------------------------------------------------------------------------
57
+ 0.000 0.000 0.000 0.000 1/1 Object#run_primes
58
+ 0.12% 0.02% 0.000 0.000 0.000 0.000 1 Object#find_largest
59
+ 0.000 0.000 0.000 0.000 1/1001 Integer#upto
60
+ 0.000 0.000 0.000 0.000 1/1 Array#first
61
+ --------------------------------------------------------------------------------
62
+ 0.000 0.000 0.000 0.000 1/1 Object#make_random_array
63
+ 0.01% 0.00% 0.000 0.000 0.000 0.000 1 Class#new
64
+ 0.000 0.000 0.000 0.000 1/1 Array#initialize
65
+ --------------------------------------------------------------------------------
66
+ 0.000 0.000 0.000 0.000 1/1 Class#new
67
+ 0.01% 0.01% 0.000 0.000 0.000 0.000 1 Array#initialize
68
+ --------------------------------------------------------------------------------
69
+ 0.000 0.000 0.000 0.000 1/1 Object#find_largest
70
+ 0.00% 0.00% 0.000 0.000 0.000 0.000 1 Array#first
71
+
72
+
73
+ == Overview
74
+
75
+ Dashed lines divide the report into entries, with one entry per method. Entries
76
+ are sorted by total time which is the time spent in the method plus its
77
+ children.
78
+
79
+ Each entry has a primary line demarked by values in the %total and %self
80
+ columns. The primary line represents the method being profiled. Lines above it
81
+ are the methods that called this method (parents) while the lines below it are
82
+ the methods it called (children).
83
+
84
+ All values are in seconds. For the primary line, the columns represent:
85
+
86
+ %total - The percentage of time spent in this method and its children
87
+ %self - The percentage of time spent in this method
88
+ total - The time spent in this method and its children.
89
+ self - The time spent in this method.
90
+ wait - The time spent waiting for other threads in this method.
91
+ child - The time spent in this method's children.
92
+ calls - The number of times this method was called.
93
+ name - The name of the method.
94
+
95
+ The interpretation of method names is:
96
+ MyObject#test - An instance method "test" of the class "MyObject"
97
+ <Object:MyObject>#test - The <> characters indicate a singleton method on a singleton class.
98
+
99
+ For example, we see that 97.74% of the time was spent in Object#is_prime and its
100
+ children. Of that time, almost everything was contributed by Integer#upto.
101
+ Overall, Object#is_prime was called 1001 times and 1000 of those calls were made
102
+ by Object#is_prime.
103
+
104
+
105
+ == Parents
106
+
107
+ In each entry, the lines above the primary line are the methods that called the
108
+ current method. If the current method is a root method then no parents are
109
+ shown.
110
+
111
+ For parent lines, the columns represent:
112
+
113
+ total - The time spent in the current method and its children on behalf of the parent method.
114
+ self - The time spent in this method on behalf of the parent method.
115
+ child - The time spent in this method's children on behalf of the parent.
116
+ wait - The time spent waiting for other threads in this method's children on behalf of the parent.
117
+ calls - The number of times the parent method called the current method vs. the total number of calls of the current method.
118
+
119
+ Looking at the main entry for Integer#upto, we see that it was called 1000 times
120
+ from Object#is_prime and 1 time from find_largest.
121
+
122
+
123
+ == Children
124
+
125
+ In each entry, the lines below the primary line are the methods that
126
+ the current method called. If the current method is a leaf method then
127
+ no children are shown.
128
+
129
+ For children lines, the columns represent:
130
+
131
+ total - The time spent in the child, and its descendants, on behalf of the current method
132
+ self - The time spent in the child on behalf of the current method.
133
+ wait - The time spent waiting for other threads in the child's and its descendants on behalf of the current method.
134
+ child - The time spent in the child's descendants on behalf of the current method.
135
+ calls - The number of times the child method was called by the current method vs. the total number of calls of the child method.
136
+
137
+ If we look at the main entry for Objext#run_primes, we see that it called three
138
+ other methods - Object#find_primes, Object#make_random_array and
139
+ Object#find_largest.
@@ -1,7 +1,12 @@
1
1
  require "mkmf"
2
2
 
3
+ if RUBY_ENGINE != "ruby"
4
+ STDERR.puts("\n\n***** This gem is MRI-specific. It does not support #{RUBY_ENGINE}. *****\n\n")
5
+ exit(1)
6
+ end
7
+
3
8
  if RUBY_VERSION < "1.9.3"
4
- STDERR.puts("Ruby version #{RUBY_VERSION} is no longer supported. Please upgrade to 1.9.3 or higher")
9
+ STDERR.puts("\n\n***** Ruby version #{RUBY_VERSION} is no longer supported. Please upgrade to 1.9.3 or higher. *****\n\n")
5
10
  exit(1)
6
11
  end
7
12
 
@@ -2,13 +2,14 @@
2
2
 
3
3
  module RubyProf
4
4
  class AggregateCallInfo
5
- attr_reader :call_infos
5
+ attr_reader :call_infos, :method_info
6
6
 
7
- def initialize(call_infos)
7
+ def initialize(call_infos, method_info)
8
8
  if call_infos.length == 0
9
9
  raise(ArgumentError, "Must specify at least one call info.")
10
10
  end
11
11
  @call_infos = call_infos
12
+ @method_info = method_info
12
13
  end
13
14
 
14
15
  def target
@@ -30,23 +31,23 @@ module RubyProf
30
31
  end
31
32
 
32
33
  def total_time
33
- aggregate_without_recursion(:total_time)
34
+ aggregate_roots(:total_time)
34
35
  end
35
36
 
36
37
  def self_time
37
- aggregate_without_recursion(:self_time)
38
+ aggregate_roots(:self_time)
38
39
  end
39
40
 
40
41
  def wait_time
41
- aggregate_without_recursion(:wait_time)
42
+ aggregate_roots(:wait_time)
42
43
  end
43
44
 
44
45
  def children_time
45
- aggregate_without_recursion(:children_time)
46
+ aggregate_roots(:children_time)
46
47
  end
47
48
 
48
49
  def called
49
- aggregate(:called)
50
+ aggregate_all(:called)
50
51
  end
51
52
 
52
53
  def to_s
@@ -55,15 +56,20 @@ module RubyProf
55
56
 
56
57
  private
57
58
 
58
- def aggregate(method_name)
59
+ # return all call_infos which are not (grand) children of any other node in the list of given call_infos
60
+ def roots
61
+ @roots ||= method_info.recursive? ? CallInfo.roots_of(call_infos) : call_infos
62
+ end
63
+
64
+ def aggregate_all(method_name)
59
65
  call_infos.inject(0) do |sum, call_info|
60
66
  sum + call_info.send(method_name)
61
67
  end
62
68
  end
63
69
 
64
- def aggregate_without_recursion(method_name)
65
- call_infos.inject(0) do |sum, call_info|
66
- call_info.recursive ? sum : sum + call_info.send(method_name)
70
+ def aggregate_roots(method_name)
71
+ roots.inject(0) do |sum, call_info|
72
+ sum + call_info.send(method_name)
67
73
  end
68
74
  end
69
75
  end
@@ -11,28 +11,13 @@ module RubyProf
11
11
 
12
12
  attr_reader :recursive
13
13
 
14
- def non_recursive?
15
- @non_recursive
16
- end
17
-
18
14
  def detect_recursion(visited_methods = Hash.new(0))
19
- @recursive = (visited_methods[target] += 1) > 1
20
- @non_recursive = true
21
- children.each do |child|
22
- @non_recursive = false if child.detect_recursion(visited_methods)
23
- end
24
- visited_methods.delete(target) if (visited_methods[target] -= 1) == 0
25
- return !@non_recursive
26
- end
27
-
28
- def recalc_recursion(visited_methods = Hash.new(0))
29
- return if @non_recursive
30
- target.clear_cached_values_which_depend_on_recursiveness
31
15
  @recursive = (visited_methods[target] += 1) > 1
32
16
  children.each do |child|
33
- child.recalc_recursion(visited_methods)
17
+ child.detect_recursion(visited_methods)
34
18
  end
35
19
  visited_methods.delete(target) if (visited_methods[target] -= 1) == 0
20
+ return @recursive
36
21
  end
37
22
 
38
23
  def children_time
@@ -22,18 +22,10 @@ module RubyProf
22
22
  call_infos.each(&:detect_recursion)
23
23
  end
24
24
 
25
- def recalc_recursion
26
- call_infos.each(&:recalc_recursion)
27
- end
28
-
29
- def clear_cached_values_which_depend_on_recursiveness
30
- @total_time = @self_time = @wait_time = @children_time = nil
31
- end
32
-
33
25
  def called
34
26
  @called ||= begin
35
27
  call_infos.inject(0) do |sum, call_info|
36
- sum += call_info.called
28
+ sum + call_info.called
37
29
  end
38
30
  end
39
31
  end
@@ -87,15 +79,7 @@ module RubyProf
87
79
  end
88
80
 
89
81
  def recursive?
90
- call_infos.detect(&:recursive)
91
- end
92
-
93
- def non_recursive?
94
- non_recursive == 1
95
- end
96
-
97
- def non_recursive
98
- @non_recursive ||= call_infos.all?(&:non_recursive?) ? 1 : 0
82
+ (@recursive ||= call_infos.detect(&:recursive) ? :true : :false) == :true
99
83
  end
100
84
 
101
85
  def children
@@ -107,26 +91,26 @@ module RubyProf
107
91
  end
108
92
 
109
93
  def aggregate_parents
110
- # Group call info's based on their parents
94
+ # group call infos based on their parents
111
95
  groups = self.call_infos.each_with_object({}) do |call_info, hash|
112
96
  key = call_info.parent ? call_info.parent.target : self
113
97
  (hash[key] ||= []) << call_info
114
98
  end
115
99
 
116
100
  groups.map do |key, value|
117
- AggregateCallInfo.new(value)
101
+ AggregateCallInfo.new(value, self)
118
102
  end
119
103
  end
120
104
 
121
105
  def aggregate_children
122
- # Group call info's based on their targets
106
+ # group call infos based on their targets
123
107
  groups = self.children.each_with_object({}) do |call_info, hash|
124
108
  key = call_info.target
125
109
  (hash[key] ||= []) << call_info
126
110
  end
127
111
 
128
112
  groups.map do |key, value|
129
- AggregateCallInfo.new(value)
113
+ AggregateCallInfo.new(value, self)
130
114
  end
131
115
  end
132
116