ruby-prof 1.5.0 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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/thread_test.rb
CHANGED
@@ -8,11 +8,6 @@ require_relative './call_tree_builder'
|
|
8
8
|
|
9
9
|
# -- Tests ----
|
10
10
|
class ThreadTest < TestCase
|
11
|
-
def setup
|
12
|
-
# Need to use wall time for this test due to the sleep calls
|
13
|
-
RubyProf::measure_mode = RubyProf::WALL_TIME
|
14
|
-
end
|
15
|
-
|
16
11
|
def test_initialize
|
17
12
|
method_info = RubyProf::MethodInfo.new(Array, :size)
|
18
13
|
call_tree = RubyProf::CallTree.new(method_info)
|
@@ -22,41 +17,109 @@ class ThreadTest < TestCase
|
|
22
17
|
assert(thread)
|
23
18
|
assert(thread.id)
|
24
19
|
assert(thread.fiber_id)
|
20
|
+
|
21
|
+
assert_equal(1, thread.methods.size)
|
22
|
+
assert_same(method_info, thread.methods[0])
|
25
23
|
end
|
26
24
|
|
27
25
|
def test_merge
|
28
26
|
call_tree_1 = create_call_tree_1
|
29
27
|
thread_1 = RubyProf::Thread.new(call_tree_1, Thread.current, Fiber.current)
|
28
|
+
assert_equal(6, thread_1.methods.size)
|
30
29
|
|
31
30
|
call_tree_2 = create_call_tree_2
|
32
31
|
thread_2 = RubyProf::Thread.new(call_tree_2, Thread.current, Fiber.current)
|
32
|
+
assert_equal(6, thread_2.methods.size)
|
33
33
|
|
34
34
|
thread_1.merge!(thread_2)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
assert_in_delta(11.6, thread_1.
|
35
|
+
assert_equal(7, thread_1.methods.size)
|
36
|
+
|
37
|
+
# Method times
|
38
|
+
assert_in_delta(11.6, thread_1.methods[0].total_time, 0.00001) # root
|
39
|
+
assert_in_delta(4.1, thread_1.methods[1].total_time, 0.00001) # a
|
40
|
+
assert_in_delta(1.5, thread_1.methods[2].total_time, 0.00001) # aa
|
41
|
+
assert_in_delta(2.6, thread_1.methods[3].total_time, 0.00001) # ab
|
42
|
+
assert_in_delta(7.5, thread_1.methods[4].total_time, 0.00001) # b
|
43
|
+
assert_in_delta(6.6, thread_1.methods[5].total_time, 0.00001) # bb
|
44
|
+
assert_in_delta(0.9, thread_1.methods[6].total_time, 0.00001) # ba
|
45
|
+
|
46
|
+
# Root
|
47
|
+
call_tree = call_tree_1
|
48
|
+
assert_equal(:root, call_tree.target.method_name)
|
49
|
+
assert_in_delta(11.6, call_tree.total_time, 0.00001)
|
50
|
+
assert_in_delta(0, call_tree.self_time, 0.00001)
|
51
|
+
assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
52
|
+
assert_in_delta(11.6, call_tree.children_time, 0.00001)
|
53
|
+
|
54
|
+
# a
|
55
|
+
call_tree = call_tree_1.children[0]
|
56
|
+
assert_equal(:a, call_tree.target.method_name)
|
57
|
+
assert_in_delta(4.1, call_tree.total_time, 0.00001)
|
58
|
+
assert_in_delta(0, call_tree.self_time, 0.00001)
|
59
|
+
assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
60
|
+
assert_in_delta(4.1, call_tree.children_time, 0.00001)
|
61
|
+
|
62
|
+
# aa
|
63
|
+
call_tree = call_tree_1.children[0].children[0]
|
64
|
+
assert_equal(:aa, call_tree.target.method_name)
|
65
|
+
assert_in_delta(1.5, call_tree.total_time, 0.00001)
|
66
|
+
assert_in_delta(1.5, call_tree.self_time, 0.00001)
|
67
|
+
assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
68
|
+
assert_in_delta(0.0, call_tree.children_time, 0.00001)
|
69
|
+
|
70
|
+
# ab
|
71
|
+
call_tree = call_tree_1.children[0].children[1]
|
72
|
+
assert_equal(:ab, call_tree.target.method_name)
|
73
|
+
assert_in_delta(2.6, call_tree.total_time, 0.00001)
|
74
|
+
assert_in_delta(2.6, call_tree.self_time, 0.00001)
|
75
|
+
assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
76
|
+
assert_in_delta(0.0, call_tree.children_time, 0.00001)
|
77
|
+
|
78
|
+
# # b
|
79
|
+
# call_tree = call_tree_1.children[1]
|
80
|
+
# assert_equal(:b, call_tree.target.method_name)
|
81
|
+
# assert_in_delta(7.5, call_tree.total_time, 0.00001)
|
82
|
+
# assert_in_delta(0, call_tree.self_time, 0.00001)
|
83
|
+
# assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
84
|
+
# assert_in_delta(7.5, call_tree.children_time, 0.00001)
|
85
|
+
|
86
|
+
# bb
|
87
|
+
# call_tree = call_tree_1.children[1].children[0]
|
88
|
+
# assert_equal(:bb, call_tree.target.method_name)
|
89
|
+
# assert_in_delta(6.6, call_tree.total_time, 0.00001)
|
90
|
+
# assert_in_delta(6.6, call_tree.self_time, 0.00001)
|
91
|
+
# assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
92
|
+
# assert_in_delta(0.0, call_tree.children_time, 0.00001)
|
93
|
+
|
94
|
+
# ba
|
95
|
+
call_tree = call_tree_1.children[1].children[1]
|
96
|
+
assert_equal(:ba, call_tree.target.method_name)
|
97
|
+
assert_in_delta(0.9, call_tree.total_time, 0.00001)
|
98
|
+
assert_in_delta(0.7, call_tree.self_time, 0.00001)
|
99
|
+
assert_in_delta(0.2, call_tree.wait_time, 0.00001)
|
100
|
+
assert_in_delta(0.0, call_tree.children_time, 0.00001)
|
39
101
|
end
|
40
102
|
|
41
103
|
def test_thread_count
|
42
|
-
RubyProf.
|
104
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
|
105
|
+
thread = Thread.new do
|
106
|
+
sleep(1)
|
107
|
+
end
|
43
108
|
|
44
|
-
|
45
|
-
sleep(1)
|
109
|
+
thread.join
|
46
110
|
end
|
47
|
-
|
48
|
-
thread.join
|
49
|
-
result = RubyProf.stop
|
50
111
|
assert_equal(2, result.threads.length)
|
51
112
|
end
|
52
113
|
|
53
114
|
def test_thread_identity
|
54
|
-
RubyProf.
|
115
|
+
profile = RubyProf::Profile.new(measure_mode: RubyProf::WALL_TIME)
|
116
|
+
profile.start
|
117
|
+
|
55
118
|
sleep_thread = Thread.new do
|
56
119
|
sleep(1)
|
57
120
|
end
|
58
121
|
sleep_thread.join
|
59
|
-
result =
|
122
|
+
result = profile.stop
|
60
123
|
|
61
124
|
thread_ids = result.threads.map {|thread| thread.id}.sort
|
62
125
|
threads = [Thread.current, sleep_thread]
|
@@ -73,7 +136,9 @@ class ThreadTest < TestCase
|
|
73
136
|
end
|
74
137
|
|
75
138
|
def test_thread_timings
|
76
|
-
RubyProf.
|
139
|
+
profile = RubyProf::Profile.new(measure_mode: RubyProf::WALL_TIME)
|
140
|
+
profile.start
|
141
|
+
|
77
142
|
thread = Thread.new do
|
78
143
|
sleep 0
|
79
144
|
# force it to hit thread.join, below, first
|
@@ -83,7 +148,7 @@ class ThreadTest < TestCase
|
|
83
148
|
sleep(1)
|
84
149
|
end
|
85
150
|
thread.join
|
86
|
-
result =
|
151
|
+
result = profile.stop
|
87
152
|
|
88
153
|
# Check background thread
|
89
154
|
assert_equal(2, result.threads.length)
|
@@ -30,7 +30,7 @@ class UniqueCallPathTest < TestCase
|
|
30
30
|
def test_root
|
31
31
|
unique_call_path = UniqueCallPath.new
|
32
32
|
|
33
|
-
result = RubyProf.profile do
|
33
|
+
result = RubyProf::Profile.profile do
|
34
34
|
unique_call_path.method_a(1)
|
35
35
|
end
|
36
36
|
|
@@ -41,7 +41,7 @@ class UniqueCallPathTest < TestCase
|
|
41
41
|
def test_root_children
|
42
42
|
unique_call_path = UniqueCallPath.new
|
43
43
|
|
44
|
-
result = RubyProf.profile do
|
44
|
+
result = RubyProf::Profile.profile do
|
45
45
|
unique_call_path.method_a(1)
|
46
46
|
unique_call_path.method_k(2)
|
47
47
|
end
|
@@ -59,7 +59,7 @@ class UniqueCallPathTest < TestCase
|
|
59
59
|
def test_children_of
|
60
60
|
unique_call_path = UniqueCallPath.new
|
61
61
|
|
62
|
-
result = RubyProf.profile do
|
62
|
+
result = RubyProf::Profile.profile do
|
63
63
|
unique_call_path.method_a(1)
|
64
64
|
unique_call_path.method_k(2)
|
65
65
|
end
|
@@ -92,7 +92,7 @@ class UniqueCallPathTest < TestCase
|
|
92
92
|
def test_unique_path
|
93
93
|
unique_call_path = UniqueCallPath.new
|
94
94
|
|
95
|
-
result = RubyProf.profile do
|
95
|
+
result = RubyProf::Profile.profile do
|
96
96
|
unique_call_path.method_a(1)
|
97
97
|
unique_call_path.method_k(1)
|
98
98
|
end
|
data/test/yarv_test.rb
CHANGED
@@ -6,13 +6,13 @@ require File.expand_path('../test_helper', __FILE__)
|
|
6
6
|
# tests for bugs reported by users
|
7
7
|
class YarvTest < TestCase
|
8
8
|
def setup
|
9
|
-
|
9
|
+
super
|
10
10
|
define_methods
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_array_push_unoptimized
|
14
14
|
a = nil
|
15
|
-
result = RubyProf.profile do
|
15
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
|
16
16
|
a = self.array_push_unoptimized
|
17
17
|
end
|
18
18
|
assert_equal 2, a.length
|
@@ -21,7 +21,7 @@ class YarvTest < TestCase
|
|
21
21
|
|
22
22
|
def test_array_push_optimized
|
23
23
|
a = nil
|
24
|
-
result = RubyProf.profile do
|
24
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
|
25
25
|
a = self.array_push_optimized
|
26
26
|
end
|
27
27
|
assert_equal(2, a.length)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-prof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shugo Maeda, Charlie Savage, Roger Pack, Stefan Kaes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -112,11 +112,11 @@ files:
|
|
112
112
|
- ruby-prof.gemspec
|
113
113
|
- test/abstract_printer_test.rb
|
114
114
|
- test/alias_test.rb
|
115
|
-
- test/basic_test.rb
|
116
115
|
- test/call_tree_builder.rb
|
117
116
|
- test/call_tree_test.rb
|
118
117
|
- test/call_tree_visitor_test.rb
|
119
118
|
- test/call_trees_test.rb
|
119
|
+
- test/compatibility_test.rb
|
120
120
|
- test/duplicate_names_test.rb
|
121
121
|
- test/dynamic_method_test.rb
|
122
122
|
- test/enumerable_test.rb
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- test/measure_times.rb
|
136
136
|
- test/measure_wall_time_test.rb
|
137
137
|
- test/measurement_test.rb
|
138
|
+
- test/merge_test.rb
|
138
139
|
- test/method_info_test.rb
|
139
140
|
- test/multi_printer_test.rb
|
140
141
|
- test/no_method_class_test.rb
|
@@ -166,7 +167,7 @@ metadata:
|
|
166
167
|
bug_tracker_uri: https://github.com/ruby-prof/ruby-prof/issues
|
167
168
|
changelog_uri: https://github.com/ruby-prof/ruby-prof/blob/master/CHANGES
|
168
169
|
documentation_uri: https://ruby-prof.github.io/
|
169
|
-
source_code_uri: https://github.com/ruby-prof/ruby-prof/tree/v1.
|
170
|
+
source_code_uri: https://github.com/ruby-prof/ruby-prof/tree/v1.6.2
|
170
171
|
post_install_message:
|
171
172
|
rdoc_options: []
|
172
173
|
require_paths:
|
@@ -182,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
183
|
- !ruby/object:Gem::Version
|
183
184
|
version: '0'
|
184
185
|
requirements: []
|
185
|
-
rubygems_version: 3.4.
|
186
|
+
rubygems_version: 3.4.8
|
186
187
|
signing_key:
|
187
188
|
specification_version: 4
|
188
189
|
summary: Fast Ruby profiler
|