ruby-prof 0.18.0-x64-mingw32 → 1.1.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +32 -0
- data/LICENSE +2 -2
- data/README.rdoc +1 -483
- data/Rakefile +3 -6
- data/bin/ruby-prof +65 -30
- data/ext/ruby_prof/extconf.rb +6 -38
- data/ext/ruby_prof/rp_allocation.c +279 -0
- data/ext/ruby_prof/rp_allocation.h +31 -0
- data/ext/ruby_prof/rp_call_info.c +129 -283
- data/ext/ruby_prof/rp_call_info.h +16 -34
- data/ext/ruby_prof/rp_measure_allocations.c +25 -49
- data/ext/ruby_prof/rp_measure_memory.c +21 -56
- data/ext/ruby_prof/rp_measure_process_time.c +35 -39
- data/ext/ruby_prof/rp_measure_wall_time.c +36 -19
- data/ext/ruby_prof/rp_measurement.c +230 -0
- data/ext/ruby_prof/rp_measurement.h +50 -0
- data/ext/ruby_prof/rp_method.c +389 -389
- data/ext/ruby_prof/rp_method.h +34 -39
- data/ext/ruby_prof/rp_profile.c +895 -0
- data/ext/ruby_prof/rp_profile.h +37 -0
- data/ext/ruby_prof/rp_stack.c +103 -80
- data/ext/ruby_prof/rp_stack.h +5 -12
- data/ext/ruby_prof/rp_thread.c +143 -83
- data/ext/ruby_prof/rp_thread.h +15 -6
- data/ext/ruby_prof/ruby_prof.c +11 -757
- data/ext/ruby_prof/ruby_prof.h +4 -47
- data/ext/ruby_prof/vc/ruby_prof.vcxproj +10 -8
- data/lib/{2.6.3 → 2.6.5}/ruby_prof.so +0 -0
- data/lib/ruby-prof.rb +2 -18
- data/lib/ruby-prof/assets/call_stack_printer.html.erb +713 -0
- data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
- data/lib/ruby-prof/assets/graph_printer.html.erb +356 -0
- data/lib/ruby-prof/call_info.rb +35 -93
- data/lib/ruby-prof/call_info_visitor.rb +19 -21
- data/lib/ruby-prof/compatibility.rb +37 -107
- data/lib/ruby-prof/exclude_common_methods.rb +198 -0
- data/lib/ruby-prof/measurement.rb +14 -0
- data/lib/ruby-prof/method_info.rb +52 -83
- data/lib/ruby-prof/printers/abstract_printer.rb +73 -50
- data/lib/ruby-prof/printers/call_info_printer.rb +13 -3
- data/lib/ruby-prof/printers/call_stack_printer.rb +62 -145
- data/lib/ruby-prof/printers/call_tree_printer.rb +20 -12
- data/lib/ruby-prof/printers/dot_printer.rb +5 -5
- data/lib/ruby-prof/printers/flat_printer.rb +6 -24
- data/lib/ruby-prof/printers/graph_html_printer.rb +6 -192
- data/lib/ruby-prof/printers/graph_printer.rb +13 -15
- data/lib/ruby-prof/printers/multi_printer.rb +66 -23
- data/lib/ruby-prof/profile.rb +10 -3
- data/lib/ruby-prof/rack.rb +0 -3
- data/lib/ruby-prof/thread.rb +12 -12
- data/lib/ruby-prof/version.rb +1 -1
- data/ruby-prof.gemspec +2 -2
- data/test/abstract_printer_test.rb +0 -27
- data/test/alias_test.rb +129 -0
- data/test/basic_test.rb +41 -40
- data/test/call_info_visitor_test.rb +3 -3
- data/test/dynamic_method_test.rb +0 -2
- data/test/fiber_test.rb +11 -17
- data/test/gc_test.rb +96 -0
- data/test/line_number_test.rb +120 -39
- data/test/marshal_test.rb +119 -0
- data/test/measure_allocations.rb +30 -0
- data/test/measure_allocations_test.rb +371 -12
- data/test/measure_allocations_trace_test.rb +385 -0
- data/test/measure_memory_trace_test.rb +756 -0
- data/test/measure_process_time_test.rb +821 -33
- data/test/measure_times.rb +54 -0
- data/test/measure_wall_time_test.rb +349 -145
- data/test/multi_printer_test.rb +1 -34
- data/test/parser_timings.rb +24 -0
- data/test/pause_resume_test.rb +5 -5
- data/test/prime.rb +2 -0
- data/test/printer_call_stack_test.rb +28 -0
- data/test/printer_call_tree_test.rb +31 -0
- data/test/printer_flat_test.rb +68 -0
- data/test/printer_graph_html_test.rb +60 -0
- data/test/printer_graph_test.rb +41 -0
- data/test/printers_test.rb +32 -166
- data/test/printing_recursive_graph_test.rb +26 -72
- data/test/recursive_test.rb +72 -77
- data/test/stack_printer_test.rb +2 -15
- data/test/start_stop_test.rb +22 -25
- data/test/test_helper.rb +5 -248
- data/test/thread_test.rb +11 -54
- data/test/unique_call_path_test.rb +16 -28
- data/test/yarv_test.rb +1 -0
- metadata +28 -36
- data/examples/flat.txt +0 -50
- data/examples/graph.dot +0 -84
- data/examples/graph.html +0 -823
- data/examples/graph.txt +0 -139
- data/examples/multi.flat.txt +0 -23
- data/examples/multi.graph.html +0 -760
- data/examples/multi.grind.dat +0 -114
- data/examples/multi.stack.html +0 -547
- data/examples/stack.html +0 -547
- data/ext/ruby_prof/rp_measure.c +0 -40
- data/ext/ruby_prof/rp_measure.h +0 -45
- data/ext/ruby_prof/rp_measure_cpu_time.c +0 -136
- data/ext/ruby_prof/rp_measure_gc_runs.c +0 -73
- data/ext/ruby_prof/rp_measure_gc_time.c +0 -60
- data/lib/ruby-prof/aggregate_call_info.rb +0 -76
- data/lib/ruby-prof/assets/call_stack_printer.css.html +0 -117
- data/lib/ruby-prof/assets/call_stack_printer.js.html +0 -385
- data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +0 -83
- data/lib/ruby-prof/profile/exclude_common_methods.rb +0 -207
- data/lib/ruby-prof/profile/legacy_method_elimination.rb +0 -50
- data/test/aggregate_test.rb +0 -136
- data/test/block_test.rb +0 -74
- data/test/call_info_test.rb +0 -78
- data/test/issue137_test.rb +0 -63
- data/test/measure_cpu_time_test.rb +0 -212
- data/test/measure_gc_runs_test.rb +0 -32
- data/test/measure_gc_time_test.rb +0 -36
- data/test/measure_memory_test.rb +0 -33
- data/test/method_elimination_test.rb +0 -84
- data/test/module_test.rb +0 -45
- data/test/stack_test.rb +0 -138
@@ -25,45 +25,43 @@ end
|
|
25
25
|
# --- expected test output ---
|
26
26
|
=begin
|
27
27
|
Measure Mode: wall_time
|
28
|
-
Thread ID:
|
29
|
-
Fiber ID:
|
30
|
-
Total Time: 2.
|
31
|
-
Sort by:
|
28
|
+
Thread ID: 1307675084040
|
29
|
+
Fiber ID: 1307708787440
|
30
|
+
Total Time: 2.0939999999973224
|
31
|
+
Sort by:
|
32
32
|
|
33
|
-
%total %self total self wait child calls
|
33
|
+
%total %self total self wait child calls name
|
34
34
|
--------------------------------------------------------------------------------
|
35
|
-
|
36
|
-
|
35
|
+
1.657 0.000 0.000 1.657 2/2 Integer#times
|
36
|
+
79.13% 0.00% 1.657 0.000 0.000 1.657 2 PRGT#g
|
37
|
+
1.657 0.000 0.000 1.657 2/5 Integer#times
|
37
38
|
--------------------------------------------------------------------------------
|
38
|
-
2.
|
39
|
-
100.00%
|
40
|
-
2.040 0.000 0.000 2.040 1/5 Integer#times
|
39
|
+
2.094 2.094 0.000 0.000 12/12 Integer#times
|
40
|
+
100.00% 100.00% 2.094 2.094 0.000 0.000 12 Kernel#sleep
|
41
41
|
--------------------------------------------------------------------------------
|
42
|
-
0.
|
43
|
-
|
44
|
-
|
45
|
-
100.00% 0.00% 2.040 0.000 0.000 2.040 5 *Integer#times
|
46
|
-
2.040 2.040 0.000 0.000 12/12 Kernel#sleep
|
47
|
-
1.631 0.000 0.000 1.631 2/2 PRGT#g
|
48
|
-
0.409 0.000 0.000 0.409 2/2 PRGT#f
|
42
|
+
0.437 0.000 0.000 0.437 2/2 Integer#times
|
43
|
+
20.87% 0.00% 0.437 0.000 0.000 0.437 2 PRGT#f
|
44
|
+
0.437 0.000 0.000 0.437 2/5 Integer#times
|
49
45
|
--------------------------------------------------------------------------------
|
50
|
-
|
51
|
-
|
46
|
+
0.437 0.000 0.000 0.437 2/5 PRGT#f
|
47
|
+
1.657 0.000 0.000 1.657 2/5 PRGT#g
|
48
|
+
2.094 0.000 0.000 2.094 1/5 PRGT#run
|
49
|
+
100.00% 0.00% 2.094 0.000 0.000 2.094 5 *Integer#times
|
50
|
+
2.094 2.094 0.000 0.000 12/12 Kernel#sleep
|
51
|
+
1.657 0.000 0.000 1.657 2/2 PRGT#g
|
52
|
+
0.437 0.000 0.000 0.437 2/2 PRGT#f
|
52
53
|
--------------------------------------------------------------------------------
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
2.094 0.000 0.000 2.094 1/1 PrintingRecursiveGraphTest#setup
|
55
|
+
100.00% 0.00% 2.094 0.000 0.000 2.094 1 PRGT#run
|
56
|
+
2.094 0.000 0.000 2.094 1/5 Integer#times
|
56
57
|
--------------------------------------------------------------------------------
|
57
|
-
|
58
|
-
|
59
|
-
0.409 0.000 0.000 0.409 2/5 Integer#times
|
58
|
+
100.00% 0.00% 2.094 0.000 0.000 2.094 1 PrintingRecursiveGraphTest#setup
|
59
|
+
2.094 0.000 0.000 2.094 1/1 PRGT#run
|
60
60
|
|
61
61
|
* indicates recursively called methods
|
62
62
|
=end
|
63
63
|
|
64
64
|
class PrintingRecursiveGraphTest < TestCase
|
65
|
-
include PrinterTestHelper
|
66
|
-
|
67
65
|
def setup
|
68
66
|
# WALL_TIME so we can use sleep in our test and get same measurements on linux and windows
|
69
67
|
RubyProf::measure_mode = RubyProf::WALL_TIME
|
@@ -74,54 +72,10 @@ class PrintingRecursiveGraphTest < TestCase
|
|
74
72
|
|
75
73
|
def test_printing_rescursive_graph
|
76
74
|
printer = RubyProf::GraphPrinter.new(@result)
|
77
|
-
|
78
75
|
buffer = ''
|
79
76
|
printer.print(StringIO.new(buffer))
|
80
|
-
|
81
77
|
puts buffer if ENV['SHOW_RUBY_PROF_PRINTER_OUTPUT'] == "1"
|
82
78
|
|
83
|
-
|
84
|
-
|
85
|
-
assert( integer_times = parsed_output.metrics_for("*Integer#times") )
|
86
|
-
|
87
|
-
actual_parents = integer_times.parents.map(&:name)
|
88
|
-
expected_parents = %w(PRGT#f PRGT#g PRGT#run)
|
89
|
-
assert_equal expected_parents, actual_parents
|
90
|
-
|
91
|
-
actual_children = integer_times.children.map(&:name)
|
92
|
-
expected_children = %w(Kernel#sleep PRGT#g PRGT#f)
|
93
|
-
assert_equal expected_children, actual_children
|
94
|
-
|
95
|
-
assert( fp = integer_times.parent("PRGT#f") )
|
96
|
-
assert_in_delta(fp.total, fp.child, 0.01)
|
97
|
-
assert_equal("2/5", fp.calls)
|
98
|
-
|
99
|
-
assert( gp = integer_times.parent("PRGT#g") )
|
100
|
-
assert_in_delta(gp.total, gp.child, 0.01)
|
101
|
-
assert_equal("2/5", gp.calls)
|
102
|
-
|
103
|
-
assert( rp = integer_times.parent("PRGT#run") )
|
104
|
-
assert_in_delta(rp.total, rp.child, 0.01)
|
105
|
-
assert_equal("1/5", rp.calls)
|
106
|
-
|
107
|
-
assert_in_delta(4*fp.total, gp.total, 0.05)
|
108
|
-
assert_in_delta(fp.total + gp.total, rp.total, 0.05)
|
109
|
-
assert_in_delta(integer_times.metrics.total, rp.total, 0.05)
|
110
|
-
|
111
|
-
assert( fc = integer_times.child("PRGT#f") )
|
112
|
-
assert_in_delta(fc.total, fc.child, 0.01)
|
113
|
-
assert_equal("2/2", fc.calls)
|
114
|
-
|
115
|
-
assert( gc = integer_times.child("PRGT#g") )
|
116
|
-
assert_in_delta(gc.total, gc.child, 0.01)
|
117
|
-
assert_equal("2/2", gc.calls)
|
118
|
-
|
119
|
-
assert( ks = integer_times.child("Kernel#sleep") )
|
120
|
-
assert_in_delta(ks.total, ks.self_t, 0.01)
|
121
|
-
assert_equal("12/12", ks.calls)
|
122
|
-
|
123
|
-
assert_in_delta(4*fc.total, gc.total, 0.05)
|
124
|
-
assert_in_delta(fp.total + gc.total, ks.total, 0.05)
|
125
|
-
assert_in_delta(integer_times.metrics.total, ks.total, 0.05)
|
79
|
+
refute_nil(buffer)
|
126
80
|
end
|
127
81
|
end
|
data/test/recursive_test.rb
CHANGED
@@ -7,12 +7,10 @@ module SimpleRecursion
|
|
7
7
|
# Simple recursive test
|
8
8
|
def simple(n)
|
9
9
|
sleep(1)
|
10
|
-
n -= 1
|
11
10
|
return if n == 0
|
12
|
-
simple(n)
|
11
|
+
simple(n-1)
|
13
12
|
end
|
14
13
|
|
15
|
-
|
16
14
|
# More complicated recursive test
|
17
15
|
def render_partial(i)
|
18
16
|
sleep(1)
|
@@ -44,12 +42,9 @@ class RecursiveTest < TestCase
|
|
44
42
|
|
45
43
|
def test_simple
|
46
44
|
result = RubyProf.profile do
|
47
|
-
simple(
|
45
|
+
simple(1)
|
48
46
|
end
|
49
47
|
|
50
|
-
# Remove Fixnum+, Fixnum== for less than Ruby 1.9
|
51
|
-
result.eliminate_methods!(%w(Fixnum#== Fixnum#-))
|
52
|
-
|
53
48
|
methods = result.threads.first.methods.sort.reverse
|
54
49
|
assert_equal(3, methods.length)
|
55
50
|
|
@@ -57,56 +52,60 @@ class RecursiveTest < TestCase
|
|
57
52
|
method = methods[0]
|
58
53
|
assert_equal('RecursiveTest#test_simple', method.full_name)
|
59
54
|
assert_equal(1, method.called)
|
55
|
+
refute(method.recursive?)
|
60
56
|
assert_in_delta(2, method.total_time, 0.1)
|
61
57
|
assert_in_delta(0, method.self_time, 0.01)
|
62
58
|
assert_in_delta(0, method.wait_time, 0.01)
|
63
59
|
assert_in_delta(2, method.children_time, 0.1)
|
64
60
|
|
65
|
-
assert_equal(1, method.
|
66
|
-
call_info = method.
|
67
|
-
|
68
|
-
|
69
|
-
assert_equal(1,
|
61
|
+
assert_equal(1, method.callers.length)
|
62
|
+
call_info = method.callers[0]
|
63
|
+
assert_nil(call_info.parent)
|
64
|
+
|
65
|
+
assert_equal(1, method.callees.length)
|
66
|
+
call_info = method.callees[0]
|
67
|
+
assert_equal('SimpleRecursion#simple', call_info.target.full_name)
|
70
68
|
|
71
69
|
# Method 1: SimpleRecursion#simple
|
72
70
|
method = methods[1]
|
73
71
|
assert_equal('SimpleRecursion#simple', method.full_name)
|
74
72
|
assert_equal(2, method.called)
|
73
|
+
assert(method.recursive?)
|
75
74
|
assert_in_delta(2, method.total_time, 0.1)
|
76
75
|
assert_in_delta(0, method.self_time, 0.1)
|
77
76
|
assert_in_delta(0, method.wait_time, 0.1)
|
78
77
|
assert_in_delta(2, method.children_time, 0.1)
|
79
78
|
|
80
|
-
assert_equal(2, method.
|
79
|
+
assert_equal(2, method.callers.length)
|
80
|
+
call_info = method.callers[0]
|
81
|
+
assert_equal('RecursiveTest#test_simple', call_info.parent.full_name)
|
81
82
|
|
82
|
-
call_info = method.
|
83
|
-
assert_equal(
|
84
|
-
assert_equal('RecursiveTest#test_simple->SimpleRecursion#simple', call_info.call_sequence)
|
85
|
-
assert(!call_info.recursive?)
|
83
|
+
call_info = method.callers[1]
|
84
|
+
assert_equal('SimpleRecursion#simple', call_info.parent.full_name)
|
86
85
|
|
87
|
-
|
88
|
-
|
89
|
-
assert_equal('
|
90
|
-
assert(call_info.recursive?)
|
86
|
+
assert_equal(2, method.callees.length)
|
87
|
+
call_info = method.callees[0]
|
88
|
+
assert_equal('Kernel#sleep', call_info.target.full_name)
|
91
89
|
|
90
|
+
call_info = method.callees[1]
|
91
|
+
assert_equal('SimpleRecursion#simple', call_info.target.full_name)
|
92
|
+
|
93
|
+
# Method 2: Kernel#sleep
|
92
94
|
method = methods[2]
|
93
95
|
assert_equal('Kernel#sleep', method.full_name)
|
94
96
|
assert_equal(2, method.called)
|
97
|
+
refute(method.recursive?)
|
95
98
|
assert_in_delta(2, method.total_time, 0.1)
|
96
99
|
assert_in_delta(2, method.self_time, 0.1)
|
97
100
|
assert_in_delta(0, method.wait_time, 0.1)
|
98
101
|
assert_in_delta(0, method.children_time, 0.1)
|
99
102
|
|
100
|
-
assert_equal(
|
101
|
-
call_info = method.
|
102
|
-
assert_equal('
|
103
|
-
assert_equal(0,
|
104
|
-
assert(!call_info.recursive?)
|
103
|
+
assert_equal(1, method.callers.length)
|
104
|
+
call_info = method.callers[0]
|
105
|
+
assert_equal('SimpleRecursion#simple', call_info.parent.full_name)
|
106
|
+
assert_equal(0, method.callees.length)
|
105
107
|
|
106
|
-
|
107
|
-
assert_equal('RecursiveTest#test_simple->SimpleRecursion#simple->SimpleRecursion#simple->Kernel#sleep', call_info.call_sequence)
|
108
|
-
assert_equal(0, call_info.children.length)
|
109
|
-
assert(!call_info.recursive?)
|
108
|
+
assert_equal(0, method.callees.length)
|
110
109
|
end
|
111
110
|
|
112
111
|
def test_cycle
|
@@ -120,96 +119,92 @@ class RecursiveTest < TestCase
|
|
120
119
|
method = methods[0]
|
121
120
|
assert_equal('RecursiveTest#test_cycle', method.full_name)
|
122
121
|
assert_equal(1, method.called)
|
122
|
+
refute(method.recursive?)
|
123
123
|
assert_in_delta(5, method.total_time, 0.1)
|
124
124
|
assert_in_delta(0, method.self_time, 0.01)
|
125
125
|
assert_in_delta(0, method.wait_time, 0.01)
|
126
126
|
assert_in_delta(5, method.children_time, 0.1)
|
127
127
|
|
128
|
-
assert_equal(1, method.
|
129
|
-
call_info = method.
|
130
|
-
|
131
|
-
|
132
|
-
|
128
|
+
assert_equal(1, method.callers.length)
|
129
|
+
call_info = method.callers[0]
|
130
|
+
assert_nil(call_info.parent)
|
131
|
+
|
132
|
+
assert_equal(1, method.callees.length)
|
133
|
+
call_info = method.callees[0]
|
134
|
+
assert_equal('SimpleRecursion#render', call_info.target.full_name)
|
133
135
|
|
134
136
|
method = methods[1]
|
135
137
|
assert_equal('SimpleRecursion#render', method.full_name)
|
136
138
|
assert_equal(1, method.called)
|
139
|
+
refute(method.recursive?)
|
137
140
|
assert_in_delta(5, method.total_time, 0.1)
|
138
141
|
assert_in_delta(0, method.self_time, 0.01)
|
139
142
|
assert_in_delta(0, method.wait_time, 0.01)
|
140
143
|
assert_in_delta(5, method.children_time, 0.1)
|
141
144
|
|
142
|
-
assert_equal(1, method.
|
143
|
-
call_info = method.
|
144
|
-
assert_equal('RecursiveTest#test_cycle
|
145
|
-
|
146
|
-
|
145
|
+
assert_equal(1, method.callers.length)
|
146
|
+
call_info = method.callers[0]
|
147
|
+
assert_equal('RecursiveTest#test_cycle', call_info.parent.full_name)
|
148
|
+
|
149
|
+
assert_equal(1, method.callees.length)
|
150
|
+
call_info = method.callees[0]
|
151
|
+
assert_equal('Integer#times', call_info.target.full_name)
|
147
152
|
|
148
153
|
method = methods[2]
|
149
154
|
assert_equal('Integer#times', method.full_name)
|
150
155
|
assert_equal(2, method.called)
|
156
|
+
assert(method.recursive?)
|
151
157
|
assert_in_delta(5, method.total_time, 0.1)
|
152
158
|
assert_in_delta(0, method.self_time, 0.1)
|
153
159
|
assert_in_delta(0, method.wait_time, 0.1)
|
154
160
|
assert_in_delta(5, method.children_time, 0.1)
|
155
161
|
|
156
|
-
assert_equal(2, method.
|
157
|
-
call_info = method.
|
158
|
-
assert_equal('
|
159
|
-
|
160
|
-
|
162
|
+
assert_equal(2, method.callers.length)
|
163
|
+
call_info = method.callers[0]
|
164
|
+
assert_equal('SimpleRecursion#render', call_info.parent.full_name)
|
165
|
+
|
166
|
+
call_info = method.callers[1]
|
167
|
+
assert_equal('SimpleRecursion#render_partial', call_info.parent.full_name)
|
161
168
|
|
162
|
-
|
163
|
-
|
164
|
-
assert_equal(
|
165
|
-
assert(call_info.recursive?)
|
169
|
+
assert_equal(1, method.callees.length)
|
170
|
+
call_info = method.callees[0]
|
171
|
+
assert_equal('SimpleRecursion#render_partial', call_info.target.full_name)
|
166
172
|
|
167
173
|
method = methods[3]
|
168
174
|
assert_equal('SimpleRecursion#render_partial', method.full_name)
|
169
175
|
assert_equal(5, method.called)
|
176
|
+
assert(method.recursive?)
|
170
177
|
assert_in_delta(5, method.total_time, 0.1)
|
171
178
|
assert_in_delta(0, method.self_time, 0.1)
|
172
179
|
assert_in_delta(0, method.wait_time, 0.01)
|
173
180
|
assert_in_delta(5, method.children_time, 0.05)
|
174
181
|
|
175
|
-
assert_equal(
|
176
|
-
call_info = method.
|
177
|
-
assert_equal('
|
178
|
-
|
179
|
-
|
182
|
+
assert_equal(2, method.callers.length)
|
183
|
+
call_info = method.callers[0]
|
184
|
+
assert_equal('Integer#times', call_info.parent.full_name)
|
185
|
+
|
186
|
+
call_info = method.callers[1]
|
187
|
+
assert_equal('SimpleRecursion#render_partial', call_info.parent.full_name)
|
188
|
+
|
189
|
+
assert_equal(3, method.callees.length)
|
190
|
+
call_info = method.callees[0]
|
191
|
+
assert_equal('Kernel#sleep', call_info.target.full_name)
|
180
192
|
|
181
|
-
call_info = method.
|
182
|
-
assert_equal('
|
183
|
-
assert_equal(1, call_info.children.length)
|
184
|
-
assert(call_info.recursive?)
|
193
|
+
call_info = method.callees[1]
|
194
|
+
assert_equal('SimpleRecursion#render_partial', call_info.target.full_name)
|
185
195
|
|
186
|
-
call_info = method.
|
187
|
-
assert_equal('
|
188
|
-
assert_equal(1, call_info.children.length)
|
189
|
-
assert(call_info.recursive?)
|
196
|
+
call_info = method.callees[2]
|
197
|
+
assert_equal('Integer#times', call_info.target.full_name)
|
190
198
|
|
191
199
|
method = methods[4]
|
192
200
|
assert_equal('Kernel#sleep', method.full_name)
|
193
201
|
assert_equal(5, method.called)
|
202
|
+
refute(method.recursive?)
|
194
203
|
assert_in_delta(5, method.total_time, 0.1)
|
195
204
|
assert_in_delta(5, method.self_time, 0.1)
|
196
205
|
assert_in_delta(0, method.wait_time, 0.01)
|
197
206
|
assert_in_delta(0, method.children_time, 0.01)
|
198
207
|
|
199
|
-
assert_equal(
|
200
|
-
call_info = method.call_infos[0]
|
201
|
-
assert_equal('RecursiveTest#test_cycle->SimpleRecursion#render->Integer#times->SimpleRecursion#render_partial->Kernel#sleep', call_info.call_sequence)
|
202
|
-
assert_equal(0, call_info.children.length)
|
203
|
-
assert(!call_info.recursive?)
|
204
|
-
|
205
|
-
call_info = method.call_infos[1]
|
206
|
-
assert_equal('RecursiveTest#test_cycle->SimpleRecursion#render->Integer#times->SimpleRecursion#render_partial->SimpleRecursion#render_partial->Kernel#sleep', call_info.call_sequence)
|
207
|
-
assert_equal(0, call_info.children.length)
|
208
|
-
assert(!call_info.recursive?)
|
209
|
-
|
210
|
-
call_info = method.call_infos[2]
|
211
|
-
assert_equal('RecursiveTest#test_cycle->SimpleRecursion#render->Integer#times->SimpleRecursion#render_partial->Integer#times->SimpleRecursion#render_partial->Kernel#sleep', call_info.call_sequence)
|
212
|
-
assert_equal(0, call_info.children.length)
|
213
|
-
assert(!call_info.recursive?)
|
208
|
+
assert_equal(0, method.callees.length)
|
214
209
|
end
|
215
210
|
end
|
data/test/stack_printer_test.rb
CHANGED
@@ -41,7 +41,7 @@ class StackPrinterTest < TestCase
|
|
41
41
|
expected_time = end_time - start_time
|
42
42
|
|
43
43
|
file_contents = nil
|
44
|
-
|
44
|
+
file_contents = print(result)
|
45
45
|
re = /Thread: (\d+)(, Fiber: (\d+))? \([\.0-9]+.[\.0-9]+% ~ ([\.0-9]+)\)/
|
46
46
|
assert_match(re, file_contents)
|
47
47
|
file_contents =~ re
|
@@ -49,23 +49,10 @@ class StackPrinterTest < TestCase
|
|
49
49
|
assert_in_delta(expected_time, actual_time, 0.1)
|
50
50
|
end
|
51
51
|
|
52
|
-
def test_method_elimination
|
53
|
-
RubyProf.start
|
54
|
-
5.times{STPT.new.a}
|
55
|
-
result = RubyProf.stop
|
56
|
-
assert_nothing_raised {
|
57
|
-
# result.dump
|
58
|
-
result.eliminate_methods!([/Integer#times/])
|
59
|
-
# $stderr.puts "================================"
|
60
|
-
# result.dump
|
61
|
-
print(result)
|
62
|
-
}
|
63
|
-
end
|
64
|
-
|
65
52
|
private
|
66
53
|
def print(result)
|
67
54
|
test = caller.first =~ /in `(.*)'/ ? $1 : "test"
|
68
|
-
testfile_name = "#{
|
55
|
+
testfile_name = "#{Dir.tmpdir}/ruby_prof_#{test}.html"
|
69
56
|
# puts "printing to #{testfile_name}"
|
70
57
|
printer = RubyProf::CallStackPrinter.new(result)
|
71
58
|
File.open(testfile_name, "w") {|f| printer.print(f, :threshold => 0, :min_percent => 0, :title => "ruby_prof #{test}")}
|
data/test/start_stop_test.rb
CHANGED
@@ -39,24 +39,15 @@ class StartStopTest < TestCase
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
42
|
def test_different_methods
|
44
43
|
method1
|
45
44
|
|
46
45
|
# Ruby prof should be stopped
|
47
46
|
assert_equal(false, RubyProf.running?)
|
48
47
|
|
49
|
-
|
50
|
-
# Length should be 4:
|
51
|
-
# StartStopTest#method1
|
52
|
-
# StartStopTest#method2
|
53
|
-
# StartStopTest#method3
|
54
|
-
# Kernel#sleep
|
55
|
-
|
56
48
|
methods = @result.threads.first.methods.sort.reverse
|
57
49
|
assert_equal(4, methods.length)
|
58
50
|
|
59
|
-
# Check StackTest#test_call_sequence
|
60
51
|
method = methods[0]
|
61
52
|
assert_equal('StartStopTest#method1', method.full_name)
|
62
53
|
assert_equal(1, method.called)
|
@@ -64,11 +55,10 @@ class StartStopTest < TestCase
|
|
64
55
|
assert_in_delta(0, method.wait_time, 0.02)
|
65
56
|
assert_in_delta(0, method.self_time, 0.02)
|
66
57
|
assert_in_delta(2, method.children_time, 0.05)
|
67
|
-
assert_equal(1, method.call_infos.length)
|
68
58
|
|
69
|
-
|
70
|
-
|
71
|
-
assert_equal(
|
59
|
+
assert_equal(1, method.callees.length)
|
60
|
+
call_info = method.callees[0]
|
61
|
+
assert_equal('StartStopTest#method2', call_info.target.full_name)
|
72
62
|
|
73
63
|
method = methods[1]
|
74
64
|
assert_equal('StartStopTest#method2', method.full_name)
|
@@ -77,11 +67,14 @@ class StartStopTest < TestCase
|
|
77
67
|
assert_in_delta(0, method.wait_time, 0.02)
|
78
68
|
assert_in_delta(0, method.self_time, 0.02)
|
79
69
|
assert_in_delta(2, method.children_time, 0.05)
|
80
|
-
assert_equal(1, method.call_infos.length)
|
81
70
|
|
82
|
-
|
83
|
-
|
84
|
-
assert_equal(
|
71
|
+
assert_equal(1, method.callers.length)
|
72
|
+
call_info = method.callers[0]
|
73
|
+
assert_equal('StartStopTest#method1', call_info.parent.full_name)
|
74
|
+
|
75
|
+
assert_equal(1, method.callees.length)
|
76
|
+
call_info = method.callees[0]
|
77
|
+
assert_equal('StartStopTest#method3', call_info.target.full_name)
|
85
78
|
|
86
79
|
method = methods[2]
|
87
80
|
assert_equal('StartStopTest#method3', method.full_name)
|
@@ -90,11 +83,14 @@ class StartStopTest < TestCase
|
|
90
83
|
assert_in_delta(0, method.wait_time, 0.02)
|
91
84
|
assert_in_delta(0, method.self_time, 0.02)
|
92
85
|
assert_in_delta(2, method.children_time, 0.02)
|
93
|
-
assert_equal(1, method.call_infos.length)
|
94
86
|
|
95
|
-
|
96
|
-
|
97
|
-
assert_equal(
|
87
|
+
assert_equal(1, method.callers.length)
|
88
|
+
call_info = method.callers[0]
|
89
|
+
assert_equal('StartStopTest#method2', call_info.parent.full_name)
|
90
|
+
|
91
|
+
assert_equal(1, method.callees.length)
|
92
|
+
call_info = method.callees[0]
|
93
|
+
assert_equal('Kernel#sleep', call_info.target.full_name)
|
98
94
|
|
99
95
|
method = methods[3]
|
100
96
|
assert_equal('Kernel#sleep', method.full_name)
|
@@ -103,10 +99,11 @@ class StartStopTest < TestCase
|
|
103
99
|
assert_in_delta(0, method.wait_time, 0.02)
|
104
100
|
assert_in_delta(2, method.self_time, 0.02)
|
105
101
|
assert_in_delta(0, method.children_time, 0.02)
|
106
|
-
assert_equal(1, method.call_infos.length)
|
107
102
|
|
108
|
-
|
109
|
-
|
110
|
-
assert_equal(
|
103
|
+
assert_equal(1, method.callers.length)
|
104
|
+
call_info = method.callers[0]
|
105
|
+
assert_equal('StartStopTest#method3', call_info.parent.full_name)
|
106
|
+
|
107
|
+
assert_equal(0, method.callees.length)
|
111
108
|
end
|
112
109
|
end
|