ruby-prof 1.5.0-x64-mingw-ucrt → 1.6.2-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +19 -0
- data/bin/ruby-prof +105 -87
- data/ext/ruby_prof/rp_allocation.c +136 -81
- data/ext/ruby_prof/rp_allocation.h +8 -6
- data/ext/ruby_prof/rp_call_tree.c +502 -457
- data/ext/ruby_prof/rp_call_tree.h +47 -44
- data/ext/ruby_prof/rp_call_trees.c +1 -1
- data/ext/ruby_prof/rp_measurement.c +10 -3
- data/ext/ruby_prof/rp_method.c +86 -79
- data/ext/ruby_prof/rp_method.h +63 -62
- data/ext/ruby_prof/rp_profile.c +933 -948
- data/ext/ruby_prof/rp_profile.h +1 -0
- data/ext/ruby_prof/rp_thread.c +433 -410
- data/ext/ruby_prof/rp_thread.h +39 -39
- data/ext/ruby_prof/vc/ruby_prof.vcxproj +6 -3
- data/lib/3.1/ruby_prof.so +0 -0
- data/lib/3.2/ruby_prof.so +0 -0
- data/lib/ruby-prof/compatibility.rb +14 -0
- data/lib/ruby-prof/printers/abstract_printer.rb +2 -1
- data/lib/ruby-prof/printers/call_tree_printer.rb +1 -1
- data/lib/ruby-prof/printers/multi_printer.rb +17 -17
- data/lib/ruby-prof/profile.rb +70 -70
- data/lib/ruby-prof/rack.rb +31 -21
- data/lib/ruby-prof/version.rb +1 -1
- data/test/abstract_printer_test.rb +1 -0
- data/test/alias_test.rb +6 -11
- data/test/call_tree_test.rb +94 -197
- data/test/call_tree_visitor_test.rb +1 -6
- data/test/call_trees_test.rb +2 -2
- data/test/{basic_test.rb → compatibility_test.rb} +8 -2
- data/test/duplicate_names_test.rb +1 -1
- data/test/dynamic_method_test.rb +1 -6
- data/test/enumerable_test.rb +1 -1
- data/test/exceptions_test.rb +2 -2
- data/test/exclude_methods_test.rb +3 -8
- data/test/exclude_threads_test.rb +4 -9
- data/test/fiber_test.rb +2 -58
- data/test/gc_test.rb +2 -2
- data/test/inverse_call_tree_test.rb +33 -34
- data/test/line_number_test.rb +1 -1
- data/test/marshal_test.rb +3 -3
- data/test/measure_allocations_test.rb +8 -17
- data/test/measure_memory_test.rb +3 -12
- data/test/measure_process_time_test.rb +32 -36
- data/test/measure_wall_time_test.rb +176 -181
- data/test/merge_test.rb +146 -0
- data/test/multi_printer_test.rb +0 -5
- data/test/no_method_class_test.rb +1 -1
- data/test/pause_resume_test.rb +12 -16
- data/test/printer_call_stack_test.rb +2 -2
- data/test/printer_call_tree_test.rb +2 -2
- data/test/printer_flat_test.rb +1 -1
- data/test/printer_graph_html_test.rb +2 -2
- data/test/printer_graph_test.rb +2 -2
- data/test/printers_test.rb +14 -20
- data/test/printing_recursive_graph_test.rb +2 -2
- data/test/recursive_test.rb +2 -7
- data/test/scheduler.rb +9 -0
- data/test/singleton_test.rb +1 -1
- data/test/stack_printer_test.rb +5 -8
- data/test/start_stop_test.rb +11 -14
- data/test/test_helper.rb +7 -0
- data/test/thread_test.rb +84 -19
- data/test/unique_call_path_test.rb +4 -4
- data/test/yarv_test.rb +3 -3
- metadata +6 -5
@@ -6,22 +6,17 @@ require_relative './measure_times'
|
|
6
6
|
|
7
7
|
class MeasureWallTimeTest < TestCase
|
8
8
|
def setup
|
9
|
-
#
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_mode
|
14
|
-
RubyProf::measure_mode = RubyProf::WALL_TIME
|
15
|
-
assert_equal(RubyProf::WALL_TIME, RubyProf::measure_mode)
|
9
|
+
# OSX on github actions are very slow so double the deltas to avoid test failures
|
10
|
+
@delta_multiplier = self.osx? && ENV["GITHUB_ACTIONS"] ? 4 : 1
|
16
11
|
end
|
17
12
|
|
18
13
|
def test_class_methods
|
19
|
-
result = RubyProf.profile do
|
14
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
|
20
15
|
RubyProf::C1.sleep_wait
|
21
16
|
end
|
22
17
|
|
23
18
|
thread = result.threads.first
|
24
|
-
assert_in_delta(0.1, thread.total_time, 0.03)
|
19
|
+
assert_in_delta(0.1, thread.total_time, 0.03 * @delta_multiplier)
|
25
20
|
|
26
21
|
methods = result.threads.first.methods.sort.reverse
|
27
22
|
assert_equal(3, methods.length)
|
@@ -32,21 +27,21 @@ class MeasureWallTimeTest < TestCase
|
|
32
27
|
assert_equal('Kernel#sleep', methods[2].full_name)
|
33
28
|
|
34
29
|
# Check times
|
35
|
-
assert_in_delta(0.1, methods[0].total_time, 0.03)
|
36
|
-
assert_in_delta(0, methods[0].wait_time, 0.03)
|
37
|
-
assert_in_delta(0, methods[0].self_time, 0.03)
|
30
|
+
assert_in_delta(0.1, methods[0].total_time, 0.03 * @delta_multiplier)
|
31
|
+
assert_in_delta(0, methods[0].wait_time, 0.03 * @delta_multiplier)
|
32
|
+
assert_in_delta(0, methods[0].self_time, 0.03 * @delta_multiplier)
|
38
33
|
|
39
|
-
assert_in_delta(0.1, methods[1].total_time, 0.03)
|
40
|
-
assert_in_delta(0, methods[1].wait_time, 0.03)
|
41
|
-
assert_in_delta(0, methods[1].self_time, 0.03)
|
34
|
+
assert_in_delta(0.1, methods[1].total_time, 0.03 * @delta_multiplier)
|
35
|
+
assert_in_delta(0, methods[1].wait_time, 0.03 * @delta_multiplier)
|
36
|
+
assert_in_delta(0, methods[1].self_time, 0.03 * @delta_multiplier)
|
42
37
|
|
43
|
-
assert_in_delta(0.1, methods[2].total_time, 0.03)
|
44
|
-
assert_in_delta(0, methods[2].wait_time, 0.03)
|
45
|
-
assert_in_delta(0.1, methods[2].self_time, 0.03)
|
38
|
+
assert_in_delta(0.1, methods[2].total_time, 0.03 * @delta_multiplier)
|
39
|
+
assert_in_delta(0, methods[2].wait_time, 0.03 * @delta_multiplier)
|
40
|
+
assert_in_delta(0.1, methods[2].self_time, 0.03 * @delta_multiplier)
|
46
41
|
end
|
47
42
|
|
48
43
|
def test_class_methods_threaded
|
49
|
-
result = RubyProf.profile do
|
44
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
|
50
45
|
background_thread = Thread.new do
|
51
46
|
RubyProf::C1.sleep_wait
|
52
47
|
end
|
@@ -56,38 +51,38 @@ class MeasureWallTimeTest < TestCase
|
|
56
51
|
assert_equal(2, result.threads.count)
|
57
52
|
|
58
53
|
thread = result.threads.first
|
59
|
-
assert_in_delta(0.1, thread.total_time, 0.03)
|
54
|
+
assert_in_delta(0.1, thread.total_time, 0.03 * @delta_multiplier)
|
60
55
|
|
61
56
|
methods = result.threads.first.methods.sort.reverse
|
62
57
|
assert_equal(4, methods.length)
|
63
58
|
|
64
59
|
# Check times
|
65
60
|
assert_equal('MeasureWallTimeTest#test_class_methods_threaded', methods[0].full_name)
|
66
|
-
assert_in_delta(0.1, methods[0].total_time, 0.03)
|
67
|
-
assert_in_delta(0.0, methods[0].wait_time, 0.03)
|
68
|
-
assert_in_delta(0.0, methods[0].self_time, 0.03)
|
69
|
-
assert_in_delta(0.1, methods[0].children_time, 0.03)
|
61
|
+
assert_in_delta(0.1, methods[0].total_time, 0.03 * @delta_multiplier)
|
62
|
+
assert_in_delta(0.0, methods[0].wait_time, 0.03 * @delta_multiplier)
|
63
|
+
assert_in_delta(0.0, methods[0].self_time, 0.03 * @delta_multiplier)
|
64
|
+
assert_in_delta(0.1, methods[0].children_time, 0.03 * @delta_multiplier)
|
70
65
|
|
71
66
|
assert_equal('Thread#join', methods[1].full_name)
|
72
|
-
assert_in_delta(0.1, methods[1].total_time, 0.03)
|
73
|
-
assert_in_delta(0.1, methods[1].wait_time, 0.03)
|
74
|
-
assert_in_delta(0.0, methods[1].self_time, 0.03)
|
75
|
-
assert_in_delta(0.0, methods[1].children_time, 0.03)
|
67
|
+
assert_in_delta(0.1, methods[1].total_time, 0.03 * @delta_multiplier)
|
68
|
+
assert_in_delta(0.1, methods[1].wait_time, 0.03 * @delta_multiplier)
|
69
|
+
assert_in_delta(0.0, methods[1].self_time, 0.03 * @delta_multiplier)
|
70
|
+
assert_in_delta(0.0, methods[1].children_time, 0.03 * @delta_multiplier)
|
76
71
|
|
77
72
|
assert_equal('<Class::Thread>#new', methods[2].full_name)
|
78
|
-
assert_in_delta(0.0, methods[2].total_time, 0.03)
|
79
|
-
assert_in_delta(0.0, methods[2].wait_time, 0.03)
|
80
|
-
assert_in_delta(0.0, methods[2].self_time, 0.03)
|
81
|
-
assert_in_delta(0.0, methods[2].children_time, 0.03)
|
73
|
+
assert_in_delta(0.0, methods[2].total_time, 0.03 * @delta_multiplier)
|
74
|
+
assert_in_delta(0.0, methods[2].wait_time, 0.03 * @delta_multiplier)
|
75
|
+
assert_in_delta(0.0, methods[2].self_time, 0.03 * @delta_multiplier)
|
76
|
+
assert_in_delta(0.0, methods[2].children_time, 0.03 * @delta_multiplier)
|
82
77
|
|
83
78
|
assert_equal('Thread#initialize', methods[3].full_name)
|
84
|
-
assert_in_delta(0.0, methods[3].total_time, 0.03)
|
85
|
-
assert_in_delta(0.0, methods[3].wait_time, 0.03)
|
86
|
-
assert_in_delta(0.0, methods[3].self_time, 0.03)
|
87
|
-
assert_in_delta(0.0, methods[3].children_time, 0.03)
|
79
|
+
assert_in_delta(0.0, methods[3].total_time, 0.03 * @delta_multiplier)
|
80
|
+
assert_in_delta(0.0, methods[3].wait_time, 0.03 * @delta_multiplier)
|
81
|
+
assert_in_delta(0.0, methods[3].self_time, 0.03 * @delta_multiplier)
|
82
|
+
assert_in_delta(0.0, methods[3].children_time, 0.03 * @delta_multiplier)
|
88
83
|
|
89
84
|
thread = result.threads.last
|
90
|
-
assert_in_delta(0.1, thread.total_time, 0.03)
|
85
|
+
assert_in_delta(0.1, thread.total_time, 0.03 * @delta_multiplier)
|
91
86
|
|
92
87
|
methods = result.threads.first.methods.sort.reverse
|
93
88
|
assert_equal(4, methods.length)
|
@@ -97,31 +92,31 @@ class MeasureWallTimeTest < TestCase
|
|
97
92
|
|
98
93
|
# Check times
|
99
94
|
assert_equal('MeasureWallTimeTest#test_class_methods_threaded', methods[0].full_name)
|
100
|
-
assert_in_delta(0.1, methods[0].total_time, 0.03)
|
101
|
-
assert_in_delta(0.0, methods[0].wait_time, 0.03)
|
102
|
-
assert_in_delta(0.0, methods[0].self_time, 0.03)
|
103
|
-
assert_in_delta(0.1, methods[0].children_time, 0.03)
|
95
|
+
assert_in_delta(0.1, methods[0].total_time, 0.03 * @delta_multiplier)
|
96
|
+
assert_in_delta(0.0, methods[0].wait_time, 0.03 * @delta_multiplier)
|
97
|
+
assert_in_delta(0.0, methods[0].self_time, 0.03 * @delta_multiplier)
|
98
|
+
assert_in_delta(0.1, methods[0].children_time, 0.03 * @delta_multiplier)
|
104
99
|
|
105
100
|
assert_equal('<Class::RubyProf::C1>#sleep_wait', methods[1].full_name)
|
106
|
-
assert_in_delta(0.1, methods[1].total_time, 0.03)
|
107
|
-
assert_in_delta(0.0, methods[1].wait_time, 0.03)
|
108
|
-
assert_in_delta(0.0, methods[1].self_time, 0.03)
|
109
|
-
assert_in_delta(0.1, methods[1].children_time, 0.03)
|
101
|
+
assert_in_delta(0.1, methods[1].total_time, 0.03 * @delta_multiplier)
|
102
|
+
assert_in_delta(0.0, methods[1].wait_time, 0.03 * @delta_multiplier)
|
103
|
+
assert_in_delta(0.0, methods[1].self_time, 0.03 * @delta_multiplier)
|
104
|
+
assert_in_delta(0.1, methods[1].children_time, 0.03 * @delta_multiplier)
|
110
105
|
|
111
106
|
assert_equal('Kernel#sleep', methods[2].full_name)
|
112
|
-
assert_in_delta(0.1, methods[2].total_time, 0.03)
|
113
|
-
assert_in_delta(0.0, methods[2].wait_time, 0.03)
|
114
|
-
assert_in_delta(0.1, methods[2].self_time, 0.03)
|
115
|
-
assert_in_delta(0.0, methods[2].children_time, 0.03)
|
107
|
+
assert_in_delta(0.1, methods[2].total_time, 0.03 * @delta_multiplier)
|
108
|
+
assert_in_delta(0.0, methods[2].wait_time, 0.03 * @delta_multiplier)
|
109
|
+
assert_in_delta(0.1, methods[2].self_time, 0.03 * @delta_multiplier)
|
110
|
+
assert_in_delta(0.0, methods[2].children_time, 0.03 * @delta_multiplier)
|
116
111
|
end
|
117
112
|
|
118
113
|
def test_instance_methods
|
119
|
-
result = RubyProf.profile do
|
114
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
|
120
115
|
RubyProf::C1.new.sleep_wait
|
121
116
|
end
|
122
117
|
|
123
118
|
thread = result.threads.first
|
124
|
-
assert_in_delta(0.2, thread.total_time, 0.03)
|
119
|
+
assert_in_delta(0.2, thread.total_time, 0.03 * @delta_multiplier)
|
125
120
|
|
126
121
|
methods = result.threads.first.methods.sort.reverse
|
127
122
|
assert_equal(5, methods.length)
|
@@ -133,37 +128,37 @@ class MeasureWallTimeTest < TestCase
|
|
133
128
|
# Check times
|
134
129
|
method = methods[0]
|
135
130
|
assert_equal('MeasureWallTimeTest#test_instance_methods', method.full_name)
|
136
|
-
assert_in_delta(0.2, method.total_time, 0.03)
|
137
|
-
assert_in_delta(0, method.wait_time, 0.03)
|
138
|
-
assert_in_delta(0, method.self_time, 0.03)
|
131
|
+
assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
|
132
|
+
assert_in_delta(0, method.wait_time, 0.03 * @delta_multiplier)
|
133
|
+
assert_in_delta(0, method.self_time, 0.03 * @delta_multiplier)
|
139
134
|
|
140
135
|
method = methods[1]
|
141
136
|
assert_equal('RubyProf::C1#sleep_wait', method.full_name)
|
142
|
-
assert_in_delta(0.2, method.total_time, 0.03)
|
143
|
-
assert_in_delta(0, method.wait_time, 0.03)
|
144
|
-
assert_in_delta(0, method.self_time, 0.03)
|
137
|
+
assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
|
138
|
+
assert_in_delta(0, method.wait_time, 0.03 * @delta_multiplier)
|
139
|
+
assert_in_delta(0, method.self_time, 0.03 * @delta_multiplier)
|
145
140
|
|
146
141
|
method = methods[2]
|
147
142
|
assert_equal('Kernel#sleep', method.full_name)
|
148
|
-
assert_in_delta(0.2, method.total_time, 0.03)
|
149
|
-
assert_in_delta(0, method.wait_time, 0.03)
|
150
|
-
assert_in_delta(0.2, method.self_time, 0.03)
|
143
|
+
assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
|
144
|
+
assert_in_delta(0, method.wait_time, 0.03 * @delta_multiplier)
|
145
|
+
assert_in_delta(0.2, method.self_time, 0.03 * @delta_multiplier)
|
151
146
|
|
152
147
|
method = methods[3]
|
153
148
|
assert_equal('Class#new', method.full_name)
|
154
|
-
assert_in_delta(0, method.total_time, 0.03)
|
155
|
-
assert_in_delta(0, method.wait_time, 0.03)
|
156
|
-
assert_in_delta(0, method.self_time, 0.03)
|
149
|
+
assert_in_delta(0, method.total_time, 0.03 * @delta_multiplier)
|
150
|
+
assert_in_delta(0, method.wait_time, 0.03 * @delta_multiplier)
|
151
|
+
assert_in_delta(0, method.self_time, 0.03 * @delta_multiplier)
|
157
152
|
|
158
153
|
method = methods[4]
|
159
154
|
assert_equal('BasicObject#initialize', method.full_name)
|
160
|
-
assert_in_delta(0, method.total_time, 0.03)
|
161
|
-
assert_in_delta(0, method.wait_time, 0.03)
|
162
|
-
assert_in_delta(0, method.self_time, 0.03)
|
155
|
+
assert_in_delta(0, method.total_time, 0.03 * @delta_multiplier)
|
156
|
+
assert_in_delta(0, method.wait_time, 0.03 * @delta_multiplier)
|
157
|
+
assert_in_delta(0, method.self_time, 0.03 * @delta_multiplier)
|
163
158
|
end
|
164
159
|
|
165
160
|
def test_instance_methods_block
|
166
|
-
result = RubyProf.profile do
|
161
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
|
167
162
|
1.times { RubyProf::C1.new.sleep_wait }
|
168
163
|
end
|
169
164
|
|
@@ -173,49 +168,49 @@ class MeasureWallTimeTest < TestCase
|
|
173
168
|
# Check times
|
174
169
|
method = methods[0]
|
175
170
|
assert_equal("MeasureWallTimeTest#test_instance_methods_block", method.full_name)
|
176
|
-
assert_in_delta(0.2, method.total_time, 0.03)
|
177
|
-
assert_in_delta(0.0, method.wait_time, 0.03)
|
178
|
-
assert_in_delta(0.0, method.self_time, 0.03)
|
179
|
-
assert_in_delta(0.2, method.children_time, 0.03)
|
171
|
+
assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
|
172
|
+
assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
|
173
|
+
assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
|
174
|
+
assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
|
180
175
|
|
181
176
|
method = methods[1]
|
182
177
|
assert_equal("Integer#times", method.full_name)
|
183
|
-
assert_in_delta(0.2, method.total_time, 0.03)
|
184
|
-
assert_in_delta(0.0, method.wait_time, 0.03)
|
185
|
-
assert_in_delta(0.0, method.self_time, 0.03)
|
186
|
-
assert_in_delta(0.2, method.children_time, 0.03)
|
178
|
+
assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
|
179
|
+
assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
|
180
|
+
assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
|
181
|
+
assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
|
187
182
|
|
188
183
|
method = methods[2]
|
189
184
|
assert_equal("RubyProf::C1#sleep_wait", method.full_name)
|
190
|
-
assert_in_delta(0.2, method.total_time, 0.03)
|
191
|
-
assert_in_delta(0.0, method.wait_time, 0.03)
|
192
|
-
assert_in_delta(0.0, method.self_time, 0.03)
|
193
|
-
assert_in_delta(0.2, method.children_time, 0.03)
|
185
|
+
assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
|
186
|
+
assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
|
187
|
+
assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
|
188
|
+
assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
|
194
189
|
|
195
190
|
method = methods[3]
|
196
191
|
assert_equal("Kernel#sleep", method.full_name)
|
197
|
-
assert_in_delta(0.2, method.total_time, 0.03)
|
198
|
-
assert_in_delta(0.0, method.wait_time, 0.03)
|
199
|
-
assert_in_delta(0.2, method.self_time, 0.03)
|
200
|
-
assert_in_delta(0.0, method.children_time, 0.03)
|
192
|
+
assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
|
193
|
+
assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
|
194
|
+
assert_in_delta(0.2, method.self_time, 0.03 * @delta_multiplier)
|
195
|
+
assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
|
201
196
|
|
202
197
|
method = methods[4]
|
203
198
|
assert_equal("Class#new", method.full_name)
|
204
|
-
assert_in_delta(0.0, method.total_time, 0.03)
|
205
|
-
assert_in_delta(0.0, method.wait_time, 0.03)
|
206
|
-
assert_in_delta(0.0, method.self_time, 0.03)
|
207
|
-
assert_in_delta(0.0, method.children_time, 0.03)
|
199
|
+
assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
|
200
|
+
assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
|
201
|
+
assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
|
202
|
+
assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
|
208
203
|
|
209
204
|
method = methods[5]
|
210
205
|
assert_equal("BasicObject#initialize", method.full_name)
|
211
|
-
assert_in_delta(0.0, method.total_time, 0.03)
|
212
|
-
assert_in_delta(0.0, method.wait_time, 0.03)
|
213
|
-
assert_in_delta(0.0, method.self_time, 0.03)
|
214
|
-
assert_in_delta(0.0, method.children_time, 0.03)
|
206
|
+
assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
|
207
|
+
assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
|
208
|
+
assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
|
209
|
+
assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
|
215
210
|
end
|
216
211
|
|
217
212
|
def test_instance_methods_threaded
|
218
|
-
result = RubyProf.profile do
|
213
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
|
219
214
|
background_thread = Thread.new do
|
220
215
|
RubyProf::C1.new.sleep_wait
|
221
216
|
end
|
@@ -225,38 +220,38 @@ class MeasureWallTimeTest < TestCase
|
|
225
220
|
assert_equal(2, result.threads.count)
|
226
221
|
|
227
222
|
thread = result.threads.first
|
228
|
-
assert_in_delta(0.2, thread.total_time, 0.03)
|
223
|
+
assert_in_delta(0.2, thread.total_time, 0.03 * @delta_multiplier)
|
229
224
|
|
230
225
|
methods = result.threads.first.methods.sort.reverse
|
231
226
|
assert_equal(4, methods.length)
|
232
227
|
|
233
228
|
# Check times
|
234
229
|
assert_equal('MeasureWallTimeTest#test_instance_methods_threaded', methods[0].full_name)
|
235
|
-
assert_in_delta(0.2, methods[0].total_time, 0.03)
|
236
|
-
assert_in_delta(0.0, methods[0].wait_time, 0.03)
|
237
|
-
assert_in_delta(0.0, methods[0].self_time, 0.03)
|
238
|
-
assert_in_delta(0.2, methods[0].children_time, 0.03)
|
230
|
+
assert_in_delta(0.2, methods[0].total_time, 0.03 * @delta_multiplier)
|
231
|
+
assert_in_delta(0.0, methods[0].wait_time, 0.03 * @delta_multiplier)
|
232
|
+
assert_in_delta(0.0, methods[0].self_time, 0.03 * @delta_multiplier)
|
233
|
+
assert_in_delta(0.2, methods[0].children_time, 0.03 * @delta_multiplier)
|
239
234
|
|
240
235
|
assert_equal('Thread#join', methods[1].full_name)
|
241
|
-
assert_in_delta(0.2, methods[1].total_time, 0.03)
|
242
|
-
assert_in_delta(0.2, methods[1].wait_time, 0.03)
|
243
|
-
assert_in_delta(0.0, methods[1].self_time, 0.03)
|
244
|
-
assert_in_delta(0.0, methods[1].children_time, 0.03)
|
236
|
+
assert_in_delta(0.2, methods[1].total_time, 0.03 * @delta_multiplier)
|
237
|
+
assert_in_delta(0.2, methods[1].wait_time, 0.03 * @delta_multiplier)
|
238
|
+
assert_in_delta(0.0, methods[1].self_time, 0.03 * @delta_multiplier)
|
239
|
+
assert_in_delta(0.0, methods[1].children_time, 0.03 * @delta_multiplier)
|
245
240
|
|
246
241
|
assert_equal('<Class::Thread>#new', methods[2].full_name)
|
247
|
-
assert_in_delta(0.0, methods[2].total_time, 0.03)
|
248
|
-
assert_in_delta(0.0, methods[2].wait_time, 0.03)
|
249
|
-
assert_in_delta(0.0, methods[2].self_time, 0.03)
|
250
|
-
assert_in_delta(0.0, methods[2].children_time, 0.03)
|
242
|
+
assert_in_delta(0.0, methods[2].total_time, 0.03 * @delta_multiplier)
|
243
|
+
assert_in_delta(0.0, methods[2].wait_time, 0.03 * @delta_multiplier)
|
244
|
+
assert_in_delta(0.0, methods[2].self_time, 0.03 * @delta_multiplier)
|
245
|
+
assert_in_delta(0.0, methods[2].children_time, 0.03 * @delta_multiplier)
|
251
246
|
|
252
247
|
assert_equal('Thread#initialize', methods[3].full_name)
|
253
|
-
assert_in_delta(0.0, methods[3].total_time, 0.03)
|
254
|
-
assert_in_delta(0.0, methods[3].wait_time, 0.03)
|
255
|
-
assert_in_delta(0.0, methods[3].self_time, 0.03)
|
256
|
-
assert_in_delta(0.0, methods[3].children_time, 0.03)
|
248
|
+
assert_in_delta(0.0, methods[3].total_time, 0.03 * @delta_multiplier)
|
249
|
+
assert_in_delta(0.0, methods[3].wait_time, 0.03 * @delta_multiplier)
|
250
|
+
assert_in_delta(0.0, methods[3].self_time, 0.03 * @delta_multiplier)
|
251
|
+
assert_in_delta(0.0, methods[3].children_time, 0.03 * @delta_multiplier)
|
257
252
|
|
258
253
|
thread = result.threads.last
|
259
|
-
assert_in_delta(0.2, thread.total_time, 0.03)
|
254
|
+
assert_in_delta(0.2, thread.total_time, 0.03 * @delta_multiplier)
|
260
255
|
|
261
256
|
methods = result.threads.first.methods.sort.reverse
|
262
257
|
assert_equal(4, methods.length)
|
@@ -266,43 +261,43 @@ class MeasureWallTimeTest < TestCase
|
|
266
261
|
|
267
262
|
# Check times
|
268
263
|
assert_equal('MeasureWallTimeTest#test_instance_methods_threaded', methods[0].full_name)
|
269
|
-
assert_in_delta(0.2, methods[0].total_time, 0.03)
|
270
|
-
assert_in_delta(0.0, methods[0].wait_time, 0.03)
|
271
|
-
assert_in_delta(0.0, methods[0].self_time, 0.03)
|
272
|
-
assert_in_delta(0.2, methods[0].children_time, 0.03)
|
264
|
+
assert_in_delta(0.2, methods[0].total_time, 0.03 * @delta_multiplier)
|
265
|
+
assert_in_delta(0.0, methods[0].wait_time, 0.03 * @delta_multiplier)
|
266
|
+
assert_in_delta(0.0, methods[0].self_time, 0.03 * @delta_multiplier)
|
267
|
+
assert_in_delta(0.2, methods[0].children_time, 0.03 * @delta_multiplier)
|
273
268
|
|
274
269
|
assert_equal('RubyProf::C1#sleep_wait', methods[1].full_name)
|
275
|
-
assert_in_delta(0.2, methods[1].total_time, 0.03)
|
276
|
-
assert_in_delta(0.0, methods[1].wait_time, 0.03)
|
277
|
-
assert_in_delta(0.0, methods[1].self_time, 0.03)
|
278
|
-
assert_in_delta(0.2, methods[1].children_time, 0.03)
|
270
|
+
assert_in_delta(0.2, methods[1].total_time, 0.03 * @delta_multiplier)
|
271
|
+
assert_in_delta(0.0, methods[1].wait_time, 0.03 * @delta_multiplier)
|
272
|
+
assert_in_delta(0.0, methods[1].self_time, 0.03 * @delta_multiplier)
|
273
|
+
assert_in_delta(0.2, methods[1].children_time, 0.03 * @delta_multiplier)
|
279
274
|
|
280
275
|
assert_equal('Kernel#sleep', methods[2].full_name)
|
281
|
-
assert_in_delta(0.2, methods[2].total_time, 0.03)
|
282
|
-
assert_in_delta(0.0, methods[2].wait_time, 0.03)
|
283
|
-
assert_in_delta(0.2, methods[2].self_time, 0.03)
|
284
|
-
assert_in_delta(0.0, methods[2].children_time, 0.03)
|
276
|
+
assert_in_delta(0.2, methods[2].total_time, 0.03 * @delta_multiplier)
|
277
|
+
assert_in_delta(0.0, methods[2].wait_time, 0.03 * @delta_multiplier)
|
278
|
+
assert_in_delta(0.2, methods[2].self_time, 0.03 * @delta_multiplier)
|
279
|
+
assert_in_delta(0.0, methods[2].children_time, 0.03 * @delta_multiplier)
|
285
280
|
|
286
281
|
assert_equal('Class#new', methods[3].full_name)
|
287
|
-
assert_in_delta(0.0, methods[3].total_time, 0.03)
|
288
|
-
assert_in_delta(0.0, methods[3].wait_time, 0.03)
|
289
|
-
assert_in_delta(0.0, methods[3].self_time, 0.03)
|
290
|
-
assert_in_delta(0.0, methods[3].children_time, 0.03)
|
282
|
+
assert_in_delta(0.0, methods[3].total_time, 0.03 * @delta_multiplier)
|
283
|
+
assert_in_delta(0.0, methods[3].wait_time, 0.03 * @delta_multiplier)
|
284
|
+
assert_in_delta(0.0, methods[3].self_time, 0.03 * @delta_multiplier)
|
285
|
+
assert_in_delta(0.0, methods[3].children_time, 0.03 * @delta_multiplier)
|
291
286
|
|
292
287
|
assert_equal('BasicObject#initialize', methods[4].full_name)
|
293
|
-
assert_in_delta(0.0, methods[4].total_time, 0.03)
|
294
|
-
assert_in_delta(0.0, methods[4].wait_time, 0.03)
|
295
|
-
assert_in_delta(0.0, methods[4].self_time, 0.03)
|
296
|
-
assert_in_delta(0.0, methods[4].children_time, 0.03)
|
288
|
+
assert_in_delta(0.0, methods[4].total_time, 0.03 * @delta_multiplier)
|
289
|
+
assert_in_delta(0.0, methods[4].wait_time, 0.03 * @delta_multiplier)
|
290
|
+
assert_in_delta(0.0, methods[4].self_time, 0.03 * @delta_multiplier)
|
291
|
+
assert_in_delta(0.0, methods[4].children_time, 0.03 * @delta_multiplier)
|
297
292
|
end
|
298
293
|
|
299
294
|
def test_module_methods
|
300
|
-
result = RubyProf.profile do
|
295
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
|
301
296
|
RubyProf::C2.sleep_wait
|
302
297
|
end
|
303
298
|
|
304
299
|
thread = result.threads.first
|
305
|
-
assert_in_delta(0.3, thread.total_time, 0.03)
|
300
|
+
assert_in_delta(0.3, thread.total_time, 0.03 * @delta_multiplier)
|
306
301
|
|
307
302
|
methods = result.threads.first.methods.sort.reverse
|
308
303
|
assert_equal(3, methods.length)
|
@@ -313,25 +308,25 @@ class MeasureWallTimeTest < TestCase
|
|
313
308
|
|
314
309
|
# Check times
|
315
310
|
assert_in_delta(0.3, methods[0].total_time, 0.1)
|
316
|
-
assert_in_delta(0, methods[0].wait_time, 0.03)
|
317
|
-
assert_in_delta(0, methods[0].self_time, 0.03)
|
311
|
+
assert_in_delta(0, methods[0].wait_time, 0.03 * @delta_multiplier)
|
312
|
+
assert_in_delta(0, methods[0].self_time, 0.03 * @delta_multiplier)
|
318
313
|
|
319
314
|
assert_in_delta(0.3, methods[1].total_time, 0.1)
|
320
|
-
assert_in_delta(0, methods[1].wait_time, 0.03)
|
321
|
-
assert_in_delta(0, methods[1].self_time, 0.03)
|
315
|
+
assert_in_delta(0, methods[1].wait_time, 0.03 * @delta_multiplier)
|
316
|
+
assert_in_delta(0, methods[1].self_time, 0.03 * @delta_multiplier)
|
322
317
|
|
323
318
|
assert_in_delta(0.3, methods[2].total_time, 0.1)
|
324
|
-
assert_in_delta(0, methods[2].wait_time, 0.03)
|
319
|
+
assert_in_delta(0, methods[2].wait_time, 0.03 * @delta_multiplier)
|
325
320
|
assert_in_delta(0.3, methods[2].self_time, 0.1)
|
326
321
|
end
|
327
322
|
|
328
323
|
def test_module_instance_methods
|
329
|
-
result = RubyProf.profile do
|
324
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
|
330
325
|
RubyProf::C2.new.sleep_wait
|
331
326
|
end
|
332
327
|
|
333
328
|
thread = result.threads.first
|
334
|
-
assert_in_delta(0.3, thread.total_time, 0.03)
|
329
|
+
assert_in_delta(0.3, thread.total_time, 0.03 * @delta_multiplier)
|
335
330
|
|
336
331
|
methods = result.threads.first.methods.sort.reverse
|
337
332
|
assert_equal(5, methods.length)
|
@@ -349,78 +344,78 @@ class MeasureWallTimeTest < TestCase
|
|
349
344
|
assert_in_delta(0, methods[0].wait_time, 0.1)
|
350
345
|
assert_in_delta(0, methods[0].self_time, 0.1)
|
351
346
|
|
352
|
-
assert_in_delta(0.3, methods[1].total_time, 0.03)
|
353
|
-
assert_in_delta(0, methods[1].wait_time, 0.03)
|
354
|
-
assert_in_delta(0, methods[1].self_time, 0.03)
|
347
|
+
assert_in_delta(0.3, methods[1].total_time, 0.03 * @delta_multiplier)
|
348
|
+
assert_in_delta(0, methods[1].wait_time, 0.03 * @delta_multiplier)
|
349
|
+
assert_in_delta(0, methods[1].self_time, 0.03 * @delta_multiplier)
|
355
350
|
|
356
|
-
assert_in_delta(0.3, methods[2].total_time, 0.03)
|
357
|
-
assert_in_delta(0, methods[2].wait_time, 0.03)
|
358
|
-
assert_in_delta(0.3, methods[2].self_time, 0.03)
|
351
|
+
assert_in_delta(0.3, methods[2].total_time, 0.03 * @delta_multiplier)
|
352
|
+
assert_in_delta(0, methods[2].wait_time, 0.03 * @delta_multiplier)
|
353
|
+
assert_in_delta(0.3, methods[2].self_time, 0.03 * @delta_multiplier)
|
359
354
|
|
360
|
-
assert_in_delta(0, methods[3].total_time, 0.03)
|
361
|
-
assert_in_delta(0, methods[3].wait_time, 0.03)
|
362
|
-
assert_in_delta(0, methods[3].self_time, 0.03)
|
355
|
+
assert_in_delta(0, methods[3].total_time, 0.03 * @delta_multiplier)
|
356
|
+
assert_in_delta(0, methods[3].wait_time, 0.03 * @delta_multiplier)
|
357
|
+
assert_in_delta(0, methods[3].self_time, 0.03 * @delta_multiplier)
|
363
358
|
|
364
|
-
assert_in_delta(0, methods[4].total_time, 0.03)
|
365
|
-
assert_in_delta(0, methods[4].wait_time, 0.03)
|
366
|
-
assert_in_delta(0, methods[4].self_time, 0.03)
|
359
|
+
assert_in_delta(0, methods[4].total_time, 0.03 * @delta_multiplier)
|
360
|
+
assert_in_delta(0, methods[4].wait_time, 0.03 * @delta_multiplier)
|
361
|
+
assert_in_delta(0, methods[4].self_time, 0.03 * @delta_multiplier)
|
367
362
|
end
|
368
363
|
|
369
364
|
def test_singleton_methods
|
370
|
-
result = RubyProf.profile do
|
365
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
|
371
366
|
RubyProf::C3.instance.sleep_wait
|
372
367
|
end
|
373
368
|
|
374
369
|
thread = result.threads.first
|
375
|
-
assert_in_delta(0.3, thread.total_time, 0.03)
|
370
|
+
assert_in_delta(0.3, thread.total_time, 0.03 * @delta_multiplier)
|
376
371
|
|
377
372
|
methods = result.threads.first.methods.sort.reverse
|
378
373
|
assert_equal(7, methods.length)
|
379
374
|
|
380
375
|
assert_equal('MeasureWallTimeTest#test_singleton_methods', methods[0].full_name)
|
381
|
-
assert_in_delta(0.3, methods[0].total_time, 0.03)
|
382
|
-
assert_in_delta(0.0, methods[0].wait_time, 0.03)
|
383
|
-
assert_in_delta(0.0, methods[0].self_time, 0.03)
|
384
|
-
assert_in_delta(0.3, methods[0].children_time, 0.03)
|
376
|
+
assert_in_delta(0.3, methods[0].total_time, 0.03 * @delta_multiplier)
|
377
|
+
assert_in_delta(0.0, methods[0].wait_time, 0.03 * @delta_multiplier)
|
378
|
+
assert_in_delta(0.0, methods[0].self_time, 0.03 * @delta_multiplier)
|
379
|
+
assert_in_delta(0.3, methods[0].children_time, 0.03 * @delta_multiplier)
|
385
380
|
|
386
381
|
assert_equal('RubyProf::C3#sleep_wait', methods[1].full_name)
|
387
|
-
assert_in_delta(0.3, methods[1].total_time, 0.03)
|
388
|
-
assert_in_delta(0.0, methods[1].wait_time, 0.03)
|
389
|
-
assert_in_delta(0.0, methods[1].self_time, 0.03)
|
390
|
-
assert_in_delta(0.3, methods[1].children_time, 0.03)
|
382
|
+
assert_in_delta(0.3, methods[1].total_time, 0.03 * @delta_multiplier)
|
383
|
+
assert_in_delta(0.0, methods[1].wait_time, 0.03 * @delta_multiplier)
|
384
|
+
assert_in_delta(0.0, methods[1].self_time, 0.03 * @delta_multiplier)
|
385
|
+
assert_in_delta(0.3, methods[1].children_time, 0.03 * @delta_multiplier)
|
391
386
|
|
392
387
|
assert_equal('Kernel#sleep', methods[2].full_name)
|
393
|
-
assert_in_delta(0.3, methods[2].total_time, 0.03)
|
394
|
-
assert_in_delta(0.0, methods[2].wait_time, 0.03)
|
395
|
-
assert_in_delta(0.3, methods[2].self_time, 0.03)
|
396
|
-
assert_in_delta(0.0, methods[2].children_time, 0.03)
|
388
|
+
assert_in_delta(0.3, methods[2].total_time, 0.03 * @delta_multiplier)
|
389
|
+
assert_in_delta(0.0, methods[2].wait_time, 0.03 * @delta_multiplier)
|
390
|
+
assert_in_delta(0.3, methods[2].self_time, 0.03 * @delta_multiplier)
|
391
|
+
assert_in_delta(0.0, methods[2].children_time, 0.03 * @delta_multiplier)
|
397
392
|
|
398
393
|
method = methods.detect {|a_method| a_method.full_name == 'Singleton::SingletonClassMethods#instance'}
|
399
394
|
assert_equal('Singleton::SingletonClassMethods#instance', method.full_name)
|
400
|
-
assert_in_delta(0.0, method.total_time, 0.03)
|
401
|
-
assert_in_delta(0.0, method.wait_time, 0.03)
|
402
|
-
assert_in_delta(0.0, method.self_time, 0.03)
|
403
|
-
assert_in_delta(0.0, method.children_time, 0.03)
|
395
|
+
assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
|
396
|
+
assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
|
397
|
+
assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
|
398
|
+
assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
|
404
399
|
|
405
400
|
method = methods.detect {|a_method| a_method.full_name == 'Thread::Mutex#synchronize'}
|
406
401
|
assert_equal('Thread::Mutex#synchronize', method.full_name)
|
407
|
-
assert_in_delta(0.0, method.total_time, 0.03)
|
408
|
-
assert_in_delta(0.0, method.wait_time, 0.03)
|
409
|
-
assert_in_delta(0.0, method.self_time, 0.03)
|
410
|
-
assert_in_delta(0.0, method.children_time, 0.03)
|
402
|
+
assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
|
403
|
+
assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
|
404
|
+
assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
|
405
|
+
assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
|
411
406
|
|
412
407
|
method = methods.detect {|a_method| a_method.full_name == 'Class#new'}
|
413
408
|
assert_equal('Class#new', method.full_name)
|
414
|
-
assert_in_delta(0.0, method.total_time, 0.03)
|
415
|
-
assert_in_delta(0.0, method.wait_time, 0.03)
|
416
|
-
assert_in_delta(0.0, method.self_time, 0.03)
|
417
|
-
assert_in_delta(0.0, method.children_time, 0.03)
|
409
|
+
assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
|
410
|
+
assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
|
411
|
+
assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
|
412
|
+
assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
|
418
413
|
|
419
414
|
method = methods.detect {|a_method| a_method.full_name == 'BasicObject#initialize'}
|
420
415
|
assert_equal('BasicObject#initialize', method.full_name)
|
421
|
-
assert_in_delta(0.0, method.total_time, 0.03)
|
422
|
-
assert_in_delta(0.0, method.wait_time, 0.03)
|
423
|
-
assert_in_delta(0.0, method.self_time, 0.03)
|
424
|
-
assert_in_delta(0.0, method.children_time, 0.03)
|
416
|
+
assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
|
417
|
+
assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
|
418
|
+
assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
|
419
|
+
assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
|
425
420
|
end
|
426
421
|
end
|