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
data/test/call_tree_test.rb
CHANGED
@@ -1,197 +1,94 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require File.expand_path('../test_helper', __FILE__)
|
4
|
-
require_relative './call_tree_builder'
|
5
|
-
require 'base64'
|
6
|
-
|
7
|
-
class CallTreeTest < Minitest::Test
|
8
|
-
def test_initialize
|
9
|
-
method_info = RubyProf::MethodInfo.new(Base64, :encode64)
|
10
|
-
call_tree = RubyProf::CallTree.new(method_info)
|
11
|
-
assert_equal(method_info, call_tree.target)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_measurement
|
15
|
-
method_info = RubyProf::MethodInfo.new(Base64, :encode64)
|
16
|
-
call_tree = RubyProf::CallTree.new(method_info)
|
17
|
-
|
18
|
-
assert_equal(0, call_tree.total_time)
|
19
|
-
assert_equal(0, call_tree.self_time)
|
20
|
-
assert_equal(0, call_tree.wait_time)
|
21
|
-
assert_equal(0, call_tree.children_time)
|
22
|
-
assert_equal(0, call_tree.called)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_compare
|
26
|
-
method_info_1 = RubyProf::MethodInfo.new(Base64, :encode64)
|
27
|
-
call_tree_1 = RubyProf::CallTree.new(method_info_1)
|
28
|
-
method_info_2 = RubyProf::MethodInfo.new(Base64, :encode64)
|
29
|
-
call_tree_2 = RubyProf::CallTree.new(method_info_2)
|
30
|
-
assert_equal(0, call_tree_1 <=> call_tree_2)
|
31
|
-
|
32
|
-
method_info_1 = RubyProf::MethodInfo.new(Base64, :decode64)
|
33
|
-
call_tree_1 = RubyProf::CallTree.new(method_info_1)
|
34
|
-
call_tree_1.measurement.total_time = 1
|
35
|
-
method_info_2 = RubyProf::MethodInfo.new(Base64, :encode64)
|
36
|
-
call_tree_2 = RubyProf::CallTree.new(method_info_2)
|
37
|
-
assert_equal(1, call_tree_1 <=> call_tree_2)
|
38
|
-
|
39
|
-
method_info_1 = RubyProf::MethodInfo.new(Base64, :decode64)
|
40
|
-
call_tree_1 = RubyProf::CallTree.new(method_info_1)
|
41
|
-
method_info_2 = RubyProf::MethodInfo.new(Base64, :encode64)
|
42
|
-
call_tree_2 = RubyProf::CallTree.new(method_info_2)
|
43
|
-
call_tree_2.measurement.total_time = 1
|
44
|
-
assert_equal(-1, call_tree_1 <=> call_tree_2)
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_to_s
|
48
|
-
method_info = RubyProf::MethodInfo.new(Base64, :encode64)
|
49
|
-
call_tree = RubyProf::CallTree.new(method_info)
|
50
|
-
assert_equal("<RubyProf::CallTree - Base64#encode64>", call_tree.to_s)
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_add_child
|
54
|
-
method_info_parent = RubyProf::MethodInfo.new(Base64, :encode64)
|
55
|
-
call_tree_parent = RubyProf::CallTree.new(method_info_parent)
|
56
|
-
|
57
|
-
method_info_child = RubyProf::MethodInfo.new(Array, :pack)
|
58
|
-
call_tree_child = RubyProf::CallTree.new(method_info_child)
|
59
|
-
|
60
|
-
assert_equal(0, call_tree_parent.children.size)
|
61
|
-
assert_nil(call_tree_child.parent)
|
62
|
-
|
63
|
-
result = call_tree_parent.add_child(call_tree_child)
|
64
|
-
assert_equal(1, call_tree_parent.children.size)
|
65
|
-
assert_equal(call_tree_child, call_tree_parent.children.first)
|
66
|
-
assert_equal(call_tree_child, result)
|
67
|
-
assert_equal(call_tree_parent, call_tree_child.parent)
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_add_child_gc
|
71
|
-
GC.stress = true
|
72
|
-
|
73
|
-
begin
|
74
|
-
method_info_parent = RubyProf::MethodInfo.new(Base64, :encode64)
|
75
|
-
call_tree_parent = RubyProf::CallTree.new(method_info_parent)
|
76
|
-
|
77
|
-
method_info_child = RubyProf::MethodInfo.new(Array, :pack)
|
78
|
-
call_tree_child = RubyProf::CallTree.new(method_info_child)
|
79
|
-
call_tree_parent.add_child(call_tree_child)
|
80
|
-
|
81
|
-
# Free the child first
|
82
|
-
call_tree_child = nil
|
83
|
-
GC.start
|
84
|
-
|
85
|
-
# Now free the parent and make sure it doesn't free the child a second time
|
86
|
-
call_tree_parent = nil
|
87
|
-
GC.start
|
88
|
-
|
89
|
-
assert(true)
|
90
|
-
ensure
|
91
|
-
GC.stress = false
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_merge
|
96
|
-
call_tree_1 = create_call_tree_1
|
97
|
-
call_tree_2 = create_call_tree_2
|
98
|
-
call_tree_1.merge!(call_tree_2)
|
99
|
-
|
100
|
-
# Root
|
101
|
-
call_tree = call_tree_1
|
102
|
-
assert_equal(:root, call_tree.target.method_name)
|
103
|
-
assert_in_delta(11.6, call_tree.total_time, 0.00001)
|
104
|
-
assert_in_delta(0, call_tree.self_time, 0.00001)
|
105
|
-
assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
106
|
-
assert_in_delta(11.6, call_tree.children_time, 0.00001)
|
107
|
-
|
108
|
-
assert_in_delta(11.6, call_tree.target.total_time, 0.00001)
|
109
|
-
assert_in_delta(0, call_tree.target.self_time, 0.00001)
|
110
|
-
assert_in_delta(0, call_tree.target.wait_time, 0.00001)
|
111
|
-
assert_in_delta(11.6, call_tree.target.children_time, 0.00001)
|
112
|
-
|
113
|
-
# a
|
114
|
-
call_tree = call_tree_1.children[0]
|
115
|
-
assert_equal(:a, call_tree.target.method_name)
|
116
|
-
|
117
|
-
assert_in_delta(4.1, call_tree.total_time, 0.00001)
|
118
|
-
assert_in_delta(0, call_tree.self_time, 0.00001)
|
119
|
-
assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
120
|
-
assert_in_delta(4.1, call_tree.children_time, 0.00001)
|
121
|
-
|
122
|
-
assert_in_delta(4.1, call_tree.target.total_time, 0.00001)
|
123
|
-
assert_in_delta(0, call_tree.target.self_time, 0.00001)
|
124
|
-
assert_in_delta(0.0, call_tree.target.wait_time, 0.00001)
|
125
|
-
assert_in_delta(4.1, call_tree.target.children_time, 0.00001)
|
126
|
-
|
127
|
-
# aa
|
128
|
-
call_tree = call_tree_1.children[0].children[0]
|
129
|
-
assert_equal(:aa, call_tree.target.method_name)
|
130
|
-
|
131
|
-
assert_in_delta(1.5, call_tree.total_time, 0.00001)
|
132
|
-
assert_in_delta(1.5, call_tree.self_time, 0.00001)
|
133
|
-
assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
134
|
-
assert_in_delta(0.0, call_tree.children_time, 0.00001)
|
135
|
-
|
136
|
-
assert_in_delta(1.5, call_tree.target.total_time, 0.00001)
|
137
|
-
assert_in_delta(1.5, call_tree.target.self_time, 0.00001)
|
138
|
-
assert_in_delta(0.0, call_tree.target.wait_time, 0.00001)
|
139
|
-
assert_in_delta(0.0, call_tree.target.children_time, 0.00001)
|
140
|
-
|
141
|
-
# ab
|
142
|
-
call_tree = call_tree_1.children[0].children[1]
|
143
|
-
assert_equal(:ab, call_tree.target.method_name)
|
144
|
-
|
145
|
-
assert_in_delta(2.6, call_tree.total_time, 0.00001)
|
146
|
-
assert_in_delta(2.6, call_tree.self_time, 0.00001)
|
147
|
-
assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
148
|
-
assert_in_delta(0.0, call_tree.children_time, 0.00001)
|
149
|
-
|
150
|
-
assert_in_delta(2.6, call_tree.target.total_time, 0.00001)
|
151
|
-
assert_in_delta(2.6, call_tree.target.self_time, 0.00001)
|
152
|
-
assert_in_delta(0.0, call_tree.target.wait_time, 0.00001)
|
153
|
-
assert_in_delta(0.0, call_tree.target.children_time, 0.00001)
|
154
|
-
|
155
|
-
# b
|
156
|
-
call_tree = call_tree_1.children[1]
|
157
|
-
assert_equal(:b, call_tree.target.method_name)
|
158
|
-
|
159
|
-
assert_in_delta(7.5, call_tree.total_time, 0.00001)
|
160
|
-
assert_in_delta(0, call_tree.self_time, 0.00001)
|
161
|
-
assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
162
|
-
assert_in_delta(7.5, call_tree.children_time, 0.00001)
|
163
|
-
|
164
|
-
assert_in_delta(7.5, call_tree.target.total_time, 0.00001)
|
165
|
-
assert_in_delta(0, call_tree.target.self_time, 0.00001)
|
166
|
-
assert_in_delta(0.0, call_tree.target.wait_time, 0.00001)
|
167
|
-
assert_in_delta(7.5, call_tree.target.children_time, 0.00001)
|
168
|
-
|
169
|
-
# bb
|
170
|
-
call_tree = call_tree_1.children[1].children[0]
|
171
|
-
assert_equal(:bb, call_tree.target.method_name)
|
172
|
-
|
173
|
-
assert_in_delta(6.6, call_tree.total_time, 0.00001)
|
174
|
-
assert_in_delta(6.6, call_tree.self_time, 0.00001)
|
175
|
-
assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
176
|
-
assert_in_delta(0.0, call_tree.children_time, 0.00001)
|
177
|
-
|
178
|
-
assert_in_delta(6.6, call_tree.target.total_time, 0.00001)
|
179
|
-
assert_in_delta(6.6, call_tree.target.self_time, 0.00001)
|
180
|
-
assert_in_delta(0.0, call_tree.target.wait_time, 0.00001)
|
181
|
-
assert_in_delta(0.0, call_tree.target.children_time, 0.00001)
|
182
|
-
|
183
|
-
# ba
|
184
|
-
call_tree = call_tree_1.children[1].children[1]
|
185
|
-
assert_equal(:ba, call_tree.target.method_name)
|
186
|
-
|
187
|
-
assert_in_delta(0.9, call_tree.total_time, 0.00001)
|
188
|
-
assert_in_delta(0.7, call_tree.self_time, 0.00001)
|
189
|
-
assert_in_delta(0.2, call_tree.wait_time, 0.00001)
|
190
|
-
assert_in_delta(0.0, call_tree.children_time, 0.00001)
|
191
|
-
|
192
|
-
assert_in_delta(0.9, call_tree.target.total_time, 0.00001)
|
193
|
-
assert_in_delta(0.7, call_tree.target.self_time, 0.00001)
|
194
|
-
assert_in_delta(0.2, call_tree.target.wait_time, 0.00001)
|
195
|
-
assert_in_delta(0.0, call_tree.target.children_time, 0.00001)
|
196
|
-
end
|
197
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('../test_helper', __FILE__)
|
4
|
+
require_relative './call_tree_builder'
|
5
|
+
require 'base64'
|
6
|
+
|
7
|
+
class CallTreeTest < Minitest::Test
|
8
|
+
def test_initialize
|
9
|
+
method_info = RubyProf::MethodInfo.new(Base64, :encode64)
|
10
|
+
call_tree = RubyProf::CallTree.new(method_info)
|
11
|
+
assert_equal(method_info, call_tree.target)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_measurement
|
15
|
+
method_info = RubyProf::MethodInfo.new(Base64, :encode64)
|
16
|
+
call_tree = RubyProf::CallTree.new(method_info)
|
17
|
+
|
18
|
+
assert_equal(0, call_tree.total_time)
|
19
|
+
assert_equal(0, call_tree.self_time)
|
20
|
+
assert_equal(0, call_tree.wait_time)
|
21
|
+
assert_equal(0, call_tree.children_time)
|
22
|
+
assert_equal(0, call_tree.called)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_compare
|
26
|
+
method_info_1 = RubyProf::MethodInfo.new(Base64, :encode64)
|
27
|
+
call_tree_1 = RubyProf::CallTree.new(method_info_1)
|
28
|
+
method_info_2 = RubyProf::MethodInfo.new(Base64, :encode64)
|
29
|
+
call_tree_2 = RubyProf::CallTree.new(method_info_2)
|
30
|
+
assert_equal(0, call_tree_1 <=> call_tree_2)
|
31
|
+
|
32
|
+
method_info_1 = RubyProf::MethodInfo.new(Base64, :decode64)
|
33
|
+
call_tree_1 = RubyProf::CallTree.new(method_info_1)
|
34
|
+
call_tree_1.measurement.total_time = 1
|
35
|
+
method_info_2 = RubyProf::MethodInfo.new(Base64, :encode64)
|
36
|
+
call_tree_2 = RubyProf::CallTree.new(method_info_2)
|
37
|
+
assert_equal(1, call_tree_1 <=> call_tree_2)
|
38
|
+
|
39
|
+
method_info_1 = RubyProf::MethodInfo.new(Base64, :decode64)
|
40
|
+
call_tree_1 = RubyProf::CallTree.new(method_info_1)
|
41
|
+
method_info_2 = RubyProf::MethodInfo.new(Base64, :encode64)
|
42
|
+
call_tree_2 = RubyProf::CallTree.new(method_info_2)
|
43
|
+
call_tree_2.measurement.total_time = 1
|
44
|
+
assert_equal(-1, call_tree_1 <=> call_tree_2)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_to_s
|
48
|
+
method_info = RubyProf::MethodInfo.new(Base64, :encode64)
|
49
|
+
call_tree = RubyProf::CallTree.new(method_info)
|
50
|
+
assert_equal("<RubyProf::CallTree - Base64#encode64>", call_tree.to_s)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_add_child
|
54
|
+
method_info_parent = RubyProf::MethodInfo.new(Base64, :encode64)
|
55
|
+
call_tree_parent = RubyProf::CallTree.new(method_info_parent)
|
56
|
+
|
57
|
+
method_info_child = RubyProf::MethodInfo.new(Array, :pack)
|
58
|
+
call_tree_child = RubyProf::CallTree.new(method_info_child)
|
59
|
+
|
60
|
+
assert_equal(0, call_tree_parent.children.size)
|
61
|
+
assert_nil(call_tree_child.parent)
|
62
|
+
|
63
|
+
result = call_tree_parent.add_child(call_tree_child)
|
64
|
+
assert_equal(1, call_tree_parent.children.size)
|
65
|
+
assert_equal(call_tree_child, call_tree_parent.children.first)
|
66
|
+
assert_equal(call_tree_child, result)
|
67
|
+
assert_equal(call_tree_parent, call_tree_child.parent)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_add_child_gc
|
71
|
+
GC.stress = true
|
72
|
+
|
73
|
+
begin
|
74
|
+
method_info_parent = RubyProf::MethodInfo.new(Base64, :encode64)
|
75
|
+
call_tree_parent = RubyProf::CallTree.new(method_info_parent)
|
76
|
+
|
77
|
+
method_info_child = RubyProf::MethodInfo.new(Array, :pack)
|
78
|
+
call_tree_child = RubyProf::CallTree.new(method_info_child)
|
79
|
+
call_tree_parent.add_child(call_tree_child)
|
80
|
+
|
81
|
+
# Free the child first
|
82
|
+
call_tree_child = nil
|
83
|
+
GC.start
|
84
|
+
|
85
|
+
# Now free the parent and make sure it doesn't free the child a second time
|
86
|
+
call_tree_parent = nil
|
87
|
+
GC.start
|
88
|
+
|
89
|
+
assert(true)
|
90
|
+
ensure
|
91
|
+
GC.stress = false
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -5,13 +5,8 @@ require File.expand_path('../test_helper', __FILE__)
|
|
5
5
|
require_relative './measure_times'
|
6
6
|
|
7
7
|
class CallTreeVisitorTest < TestCase
|
8
|
-
def setup
|
9
|
-
# Need to use wall time for this test due to the sleep calls
|
10
|
-
RubyProf::measure_mode = RubyProf::WALL_TIME
|
11
|
-
end
|
12
|
-
|
13
8
|
def test_visit
|
14
|
-
result = RubyProf.profile do
|
9
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
|
15
10
|
RubyProf::C1.sleep_wait
|
16
11
|
end
|
17
12
|
|
data/test/call_trees_test.rb
CHANGED
@@ -13,7 +13,7 @@ class CallTreesTest < TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_call_infos
|
16
|
-
result = RubyProf.profile do
|
16
|
+
result = RubyProf::Profile.profile do
|
17
17
|
some_method_1
|
18
18
|
end
|
19
19
|
|
@@ -51,7 +51,7 @@ class CallTreesTest < TestCase
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def test_gc
|
54
|
-
result = RubyProf.profile do
|
54
|
+
result = RubyProf::Profile.profile do
|
55
55
|
some_method_1
|
56
56
|
end
|
57
57
|
|
@@ -4,12 +4,18 @@
|
|
4
4
|
require File.expand_path('../test_helper', __FILE__)
|
5
5
|
require_relative './measure_times'
|
6
6
|
|
7
|
-
class
|
7
|
+
class CompatibilityTest < TestCase
|
8
8
|
def setup
|
9
|
-
|
9
|
+
super
|
10
|
+
Gem::Deprecate.skip = true
|
10
11
|
RubyProf::measure_mode = RubyProf::WALL_TIME
|
11
12
|
end
|
12
13
|
|
14
|
+
def teardown
|
15
|
+
super
|
16
|
+
Gem::Deprecate.skip = false
|
17
|
+
end
|
18
|
+
|
13
19
|
def test_running
|
14
20
|
assert(!RubyProf.running?)
|
15
21
|
RubyProf.start
|
data/test/dynamic_method_test.rb
CHANGED
@@ -24,14 +24,9 @@ class DynamicMethodTest < TestCase
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def setup
|
28
|
-
# Need to use wall time for this test due to the sleep calls
|
29
|
-
RubyProf::measure_mode = RubyProf::WALL_TIME
|
30
|
-
end
|
31
|
-
|
32
27
|
def test_dynamic_method
|
33
28
|
medley = FruitMedley.new
|
34
|
-
result = RubyProf.profile do
|
29
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
|
35
30
|
medley.apple
|
36
31
|
medley.orange
|
37
32
|
medley.banana
|
data/test/enumerable_test.rb
CHANGED
@@ -8,7 +8,7 @@ require File.expand_path('../test_helper', __FILE__)
|
|
8
8
|
|
9
9
|
class EnumerableTest < TestCase
|
10
10
|
def test_enumerable
|
11
|
-
result = RubyProf.profile do
|
11
|
+
result = RubyProf::Profile.profile do
|
12
12
|
3.times { [1,2,3].any? {|n| n} }
|
13
13
|
end
|
14
14
|
methods = if RUBY_VERSION >= "2.2.0"
|
data/test/exceptions_test.rb
CHANGED
@@ -6,7 +6,7 @@ require File.expand_path('../test_helper', __FILE__)
|
|
6
6
|
class ExceptionsTest < TestCase
|
7
7
|
def test_profile
|
8
8
|
result = begin
|
9
|
-
RubyProf.profile do
|
9
|
+
RubyProf::Profile.profile do
|
10
10
|
raise(RuntimeError, 'Test error')
|
11
11
|
end
|
12
12
|
rescue
|
@@ -16,7 +16,7 @@ class ExceptionsTest < TestCase
|
|
16
16
|
|
17
17
|
def test_profile_allows_exceptions
|
18
18
|
assert_raises(RuntimeError) do
|
19
|
-
RubyProf.profile(:allow_exceptions => true) do
|
19
|
+
RubyProf::Profile.profile(:allow_exceptions => true) do
|
20
20
|
raise(RuntimeError, 'Test error')
|
21
21
|
end
|
22
22
|
end
|
@@ -34,14 +34,9 @@ class ExcludeMethodsClass
|
|
34
34
|
end
|
35
35
|
|
36
36
|
class ExcludeMethodsTest < TestCase
|
37
|
-
def setup
|
38
|
-
# Need to use wall time for this test due to the sleep calls
|
39
|
-
RubyProf::measure_mode = RubyProf::WALL_TIME
|
40
|
-
end
|
41
|
-
|
42
37
|
def test_methods_can_be_profiled
|
43
38
|
obj = ExcludeMethodsClass.new
|
44
|
-
prf = RubyProf::Profile.new
|
39
|
+
prf = RubyProf::Profile.new(measure_mode: RubyProf::WALL_TIME)
|
45
40
|
|
46
41
|
result = prf.profile {obj.a}
|
47
42
|
methods = result.threads.first.methods.sort.reverse
|
@@ -102,7 +97,7 @@ class ExcludeMethodsTest < TestCase
|
|
102
97
|
|
103
98
|
def test_exclude_common_methods1
|
104
99
|
obj = ExcludeMethodsClass.new
|
105
|
-
prf = RubyProf::Profile.new
|
100
|
+
prf = RubyProf::Profile.new(measure_mode: RubyProf::WALL_TIME)
|
106
101
|
|
107
102
|
prf.exclude_common_methods!
|
108
103
|
|
@@ -124,7 +119,7 @@ class ExcludeMethodsTest < TestCase
|
|
124
119
|
def test_exclude_common_methods2
|
125
120
|
obj = ExcludeMethodsClass.new
|
126
121
|
|
127
|
-
result = RubyProf.profile(exclude_common: true) { 5.times {obj.a} }
|
122
|
+
result = RubyProf::Profile.profile(exclude_common: true) { 5.times {obj.a} }
|
128
123
|
methods = result.threads.first.methods.sort.reverse
|
129
124
|
|
130
125
|
assert_equal(9, methods.count)
|
@@ -26,15 +26,10 @@ class ExcludeThreadsTest < TestCase
|
|
26
26
|
thread2_proc
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
thread1.join
|
35
|
-
thread2.join
|
36
|
-
|
37
|
-
result = RubyProf.stop
|
29
|
+
result = RubyProf::Profile.profile(exclude_threads: [thread2]) do
|
30
|
+
thread1.join
|
31
|
+
thread2.join
|
32
|
+
end
|
38
33
|
|
39
34
|
assert_equal(2, result.threads.length)
|
40
35
|
|
data/test/fiber_test.rb
CHANGED
@@ -5,26 +5,9 @@ require File.expand_path('../test_helper', __FILE__)
|
|
5
5
|
require 'fiber'
|
6
6
|
require 'timeout'
|
7
7
|
require 'set'
|
8
|
-
require_relative './scheduler'
|
9
8
|
|
10
9
|
# -- Tests ----
|
11
10
|
class FiberTest < TestCase
|
12
|
-
def worker
|
13
|
-
sleep(0.5)
|
14
|
-
end
|
15
|
-
|
16
|
-
def concurrency
|
17
|
-
scheduler = Scheduler.new
|
18
|
-
Fiber.set_scheduler(scheduler)
|
19
|
-
|
20
|
-
3.times do
|
21
|
-
Fiber.schedule do |a|
|
22
|
-
worker
|
23
|
-
end
|
24
|
-
end
|
25
|
-
Fiber.scheduler.close
|
26
|
-
end
|
27
|
-
|
28
11
|
def enumerator_with_fibers
|
29
12
|
enum = Enumerator.new do |yielder|
|
30
13
|
[1,2].each do |x|
|
@@ -46,13 +29,8 @@ class FiberTest < TestCase
|
|
46
29
|
fiber.resume
|
47
30
|
end
|
48
31
|
|
49
|
-
def setup
|
50
|
-
# Need to use wall time for this test due to the sleep calls
|
51
|
-
RubyProf::measure_mode = RubyProf::WALL_TIME
|
52
|
-
end
|
53
|
-
|
54
32
|
def test_fibers
|
55
|
-
result = RubyProf.profile { enumerator_with_fibers }
|
33
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { enumerator_with_fibers }
|
56
34
|
|
57
35
|
assert_equal(2, result.threads.size)
|
58
36
|
|
@@ -142,7 +120,7 @@ class FiberTest < TestCase
|
|
142
120
|
end
|
143
121
|
|
144
122
|
def test_fiber_resume
|
145
|
-
result = RubyProf.profile { fiber_yield_resume }
|
123
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { fiber_yield_resume }
|
146
124
|
|
147
125
|
assert_equal(2, result.threads.size)
|
148
126
|
|
@@ -214,38 +192,4 @@ class FiberTest < TestCase
|
|
214
192
|
assert_in_delta(0, method.wait_time)
|
215
193
|
assert_in_delta(0, method.children_time)
|
216
194
|
end
|
217
|
-
|
218
|
-
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0')
|
219
|
-
def test_times_no_merge
|
220
|
-
result = RubyProf.profile { concurrency }
|
221
|
-
|
222
|
-
assert_equal(4, result.threads.size)
|
223
|
-
|
224
|
-
result.threads.each do |thread|
|
225
|
-
assert_in_delta(0.5, thread.call_tree.target.total_time, 0.2)
|
226
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time)
|
227
|
-
assert_in_delta(0.0, thread.call_tree.target.wait_time)
|
228
|
-
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.2)
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
def test_times_merge
|
233
|
-
result = RubyProf.profile { concurrency }
|
234
|
-
result.merge!
|
235
|
-
|
236
|
-
assert_equal(2, result.threads.size)
|
237
|
-
|
238
|
-
thread = result.threads[0]
|
239
|
-
assert_in_delta(0.5, thread.call_tree.target.total_time, 0.2)
|
240
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time)
|
241
|
-
assert_in_delta(0.0, thread.call_tree.target.wait_time)
|
242
|
-
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.2)
|
243
|
-
|
244
|
-
thread = result.threads[1]
|
245
|
-
assert_in_delta(1.5, thread.call_tree.target.total_time, 0.2)
|
246
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time)
|
247
|
-
assert_in_delta(0.0, thread.call_tree.target.wait_time)
|
248
|
-
assert_in_delta(1.5, thread.call_tree.target.children_time, 0.2)
|
249
|
-
end
|
250
|
-
end
|
251
195
|
end
|
data/test/gc_test.rb
CHANGED
@@ -6,6 +6,7 @@ Minitest::Test.i_suck_and_my_tests_are_order_dependent!
|
|
6
6
|
|
7
7
|
class GcTest < TestCase
|
8
8
|
def setup
|
9
|
+
super
|
9
10
|
GC.stress = true
|
10
11
|
end
|
11
12
|
|
@@ -18,7 +19,7 @@ class GcTest < TestCase
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def run_profile
|
21
|
-
RubyProf.profile do
|
22
|
+
RubyProf::Profile.profile do
|
22
23
|
self.some_method
|
23
24
|
end
|
24
25
|
end
|
@@ -36,7 +37,6 @@ class GcTest < TestCase
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
|
-
|
40
40
|
def test_hold_onto_method
|
41
41
|
methods = 5.times.reduce(Array.new) do |array, i|
|
42
42
|
profile = run_profile
|