ruby-prof 1.6.1-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.
@@ -1,39 +1,39 @@
1
- /* Copyright (C) 2005-2019 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
- Please see the LICENSE file for copyright and distribution information */
3
-
4
- #ifndef __RP_THREAD__
5
- #define __RP_THREAD__
6
-
7
- #include "ruby_prof.h"
8
- #include "rp_stack.h"
9
-
10
- /* Profiling information for a thread. */
11
- typedef struct thread_data_t
12
- {
13
- prof_owner_t owner; /* Who owns this object */
14
- VALUE object; /* Cache to wrapped object */
15
- VALUE fiber; /* Fiber */
16
- prof_stack_t* stack; /* Stack of frames */
17
- bool trace; /* Are we tracking this thread */
18
- prof_call_tree_t* call_tree; /* The root of the call tree*/
19
- VALUE thread_id; /* Thread id */
20
- VALUE fiber_id; /* Fiber id */
21
- VALUE methods; /* Array of RubyProf::MethodInfo */
22
- st_table* method_table; /* Methods called in the thread */
23
- } thread_data_t;
24
-
25
- void rp_init_thread(void);
26
- st_table* threads_table_create(void);
27
- thread_data_t* threads_table_lookup(void* profile, VALUE fiber);
28
- thread_data_t* threads_table_insert(void* profile, VALUE fiber);
29
- void threads_table_free(st_table* table);
30
-
31
- thread_data_t* prof_get_thread(VALUE self);
32
- VALUE prof_thread_wrap(thread_data_t* thread);
33
- void prof_thread_mark(void* data);
34
-
35
- void switch_thread(void* profile, thread_data_t* thread_data, double measurement);
36
- int pause_thread(st_data_t key, st_data_t value, st_data_t data);
37
- int unpause_thread(st_data_t key, st_data_t value, st_data_t data);
38
-
39
- #endif //__RP_THREAD__
1
+ /* Copyright (C) 2005-2019 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
+ Please see the LICENSE file for copyright and distribution information */
3
+
4
+ #ifndef __RP_THREAD__
5
+ #define __RP_THREAD__
6
+
7
+ #include "ruby_prof.h"
8
+ #include "rp_stack.h"
9
+
10
+ /* Profiling information for a thread. */
11
+ typedef struct thread_data_t
12
+ {
13
+ prof_owner_t owner; /* Who owns this object */
14
+ VALUE object; /* Cache to wrapped object */
15
+ VALUE fiber; /* Fiber */
16
+ prof_stack_t* stack; /* Stack of frames */
17
+ bool trace; /* Are we tracking this thread */
18
+ prof_call_tree_t* call_tree; /* The root of the call tree*/
19
+ VALUE thread_id; /* Thread id */
20
+ VALUE fiber_id; /* Fiber id */
21
+ VALUE methods; /* Array of RubyProf::MethodInfo */
22
+ st_table* method_table; /* Methods called in the thread */
23
+ } thread_data_t;
24
+
25
+ void rp_init_thread(void);
26
+ st_table* threads_table_create(void);
27
+ thread_data_t* threads_table_lookup(void* profile, VALUE fiber);
28
+ thread_data_t* threads_table_insert(void* profile, VALUE fiber);
29
+ void threads_table_free(st_table* table);
30
+
31
+ thread_data_t* prof_get_thread(VALUE self);
32
+ VALUE prof_thread_wrap(thread_data_t* thread);
33
+ void prof_thread_mark(void* data);
34
+
35
+ void switch_thread(void* profile, thread_data_t* thread_data, double measurement);
36
+ int pause_thread(st_data_t key, st_data_t value, st_data_t data);
37
+ int unpause_thread(st_data_t key, st_data_t value, st_data_t data);
38
+
39
+ #endif //__RP_THREAD__
@@ -104,17 +104,20 @@
104
104
  </ItemDefinitionGroup>
105
105
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
106
106
  <ClCompile>
107
- <AdditionalIncludeDirectories>C:\msys64\usr\local\ruby-3.2.0-vc\include\ruby-3.2.0\x64-mswin64_140;C:\msys64\usr\local\ruby-3.2.0-vc\include\ruby-3.2.0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
107
+ <AdditionalIncludeDirectories>C:\msys64\usr\local\ruby-3.2.1-vc\include\ruby-3.2.0\x64-mswin64_140;C:\msys64\usr\local\ruby-3.2.1-vc\include\ruby-3.2.0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
108
108
  <Optimization>Disabled</Optimization>
109
109
  <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
110
110
  <WarningLevel>Level3</WarningLevel>
111
111
  </ClCompile>
112
112
  <Link>
113
- <AdditionalLibraryDirectories>C:\msys64\usr\local\ruby-3.2.0-vc\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
113
+ <AdditionalLibraryDirectories>C:\msys64\usr\local\ruby-3.2.1-vc\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
114
114
  <AdditionalDependencies>x64-vcruntime140-ruby320.lib;%(AdditionalDependencies)</AdditionalDependencies>
115
115
  <ModuleDefinitionFile>ruby_prof.def</ModuleDefinitionFile>
116
116
  <SubSystem>Console</SubSystem>
117
117
  </Link>
118
+ <ProjectReference>
119
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>
120
+ </ProjectReference>
118
121
  </ItemDefinitionGroup>
119
122
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
120
123
  <ClCompile>
data/lib/3.1/ruby_prof.so CHANGED
Binary file
data/lib/3.2/ruby_prof.so CHANGED
Binary file
@@ -131,6 +131,7 @@ module RubyProf
131
131
 
132
132
  * MyObject#test - An instance method "test" of the class "MyObject"
133
133
  * <Object:MyObject>#test - The <> characters indicate a method on a singleton class.
134
+
134
135
  EOT
135
136
  end
136
137
  end
@@ -1,70 +1,70 @@
1
- # encoding: utf-8
2
-
3
- require 'ruby-prof/exclude_common_methods'
4
-
5
- module RubyProf
6
- class Profile
7
- def measure_mode_string
8
- case self.measure_mode
9
- when WALL_TIME
10
- "wall_time"
11
- when PROCESS_TIME
12
- "process_time"
13
- when ALLOCATIONS
14
- "allocations"
15
- when MEMORY
16
- "memory"
17
- end
18
- end
19
-
20
- # Hides methods that, when represented as a call graph, have
21
- # extremely large in and out degrees and make navigation impossible.
22
- def exclude_common_methods!
23
- ExcludeCommonMethods.apply!(self)
24
- end
25
-
26
- def exclude_methods!(mod, *method_names)
27
- [method_names].flatten.each do |method_name|
28
- exclude_method!(mod, method_name)
29
- end
30
- end
31
-
32
- def exclude_singleton_methods!(mod, *method_names)
33
- exclude_methods!(mod.singleton_class, *method_names)
34
- end
35
-
36
- # call-seq:
37
- # merge! -> self
38
- #
39
- # Merges RubyProf threads whose root call_trees reference the same target method. This is useful
40
- # when profiling code that uses a main thread/fiber to distribute work to multiple workers.
41
- # If there are tens or hundreds of workers, viewing results per worker thread/fiber can be
42
- # overwhelming. Using +merge!+ will combine the worker times together into one result.
43
- #
44
- # Note the reported time will be much greater than the actual wall time. For example, if there
45
- # are 10 workers that each run for 5 seconds, merged results will show one thread that
46
- # ran for 50 seconds.
47
- #
48
- def merge!
49
- # First group threads by their root call tree target (method). If the methods are
50
- # different than there is nothing to merge
51
- grouped = threads.group_by do |thread|
52
- thread.call_tree.target
53
- end
54
-
55
- # For each target, get the first thread. Then loop over the remaining threads,
56
- # and merge them into the first one and ten delete them. So we will be left with
57
- # one thread per target.
58
- grouped.each do |target, threads|
59
- thread = threads.shift
60
- threads.each do |other_thread|
61
- thread.merge!(other_thread)
62
- remove_thread(other_thread)
63
- end
64
- thread
65
- end
66
-
67
- self
68
- end
69
- end
70
- end
1
+ # encoding: utf-8
2
+
3
+ require 'ruby-prof/exclude_common_methods'
4
+
5
+ module RubyProf
6
+ class Profile
7
+ def measure_mode_string
8
+ case self.measure_mode
9
+ when WALL_TIME
10
+ "wall_time"
11
+ when PROCESS_TIME
12
+ "process_time"
13
+ when ALLOCATIONS
14
+ "allocations"
15
+ when MEMORY
16
+ "memory"
17
+ end
18
+ end
19
+
20
+ # Hides methods that, when represented as a call graph, have
21
+ # extremely large in and out degrees and make navigation impossible.
22
+ def exclude_common_methods!
23
+ ExcludeCommonMethods.apply!(self)
24
+ end
25
+
26
+ def exclude_methods!(mod, *method_names)
27
+ [method_names].flatten.each do |method_name|
28
+ exclude_method!(mod, method_name)
29
+ end
30
+ end
31
+
32
+ def exclude_singleton_methods!(mod, *method_names)
33
+ exclude_methods!(mod.singleton_class, *method_names)
34
+ end
35
+
36
+ # call-seq:
37
+ # merge! -> self
38
+ #
39
+ # Merges RubyProf threads whose root call_trees reference the same target method. This is useful
40
+ # when profiling code that uses a main thread/fiber to distribute work to multiple workers.
41
+ # If there are tens or hundreds of workers, viewing results per worker thread/fiber can be
42
+ # overwhelming. Using +merge!+ will combine the worker times together into one result.
43
+ #
44
+ # Note the reported time will be much greater than the actual wall time. For example, if there
45
+ # are 10 workers that each run for 5 seconds, merged results will show one thread that
46
+ # ran for 50 seconds.
47
+ #
48
+ def merge!
49
+ # First group threads by their root call tree target (method). If the methods are
50
+ # different than there is nothing to merge
51
+ grouped = threads.group_by do |thread|
52
+ thread.call_tree.target
53
+ end
54
+
55
+ # For each target, get the first thread. Then loop over the remaining threads,
56
+ # and merge them into the first one and ten delete them. So we will be left with
57
+ # one thread per target.
58
+ grouped.each do |target, threads|
59
+ thread = threads.shift
60
+ threads.each do |other_thread|
61
+ thread.merge!(other_thread)
62
+ remove_thread(other_thread)
63
+ end
64
+ thread
65
+ end
66
+
67
+ self
68
+ end
69
+ end
70
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyProf
2
- VERSION = "1.6.1"
2
+ VERSION = "1.6.2"
3
3
  end
@@ -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
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|
@@ -209,38 +192,4 @@ class FiberTest < TestCase
209
192
  assert_in_delta(0, method.wait_time)
210
193
  assert_in_delta(0, method.children_time)
211
194
  end
212
-
213
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0')
214
- def test_times_no_merge
215
- result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { concurrency }
216
-
217
- assert_equal(4, result.threads.size)
218
-
219
- result.threads.each do |thread|
220
- assert_in_delta(0.5, thread.call_tree.target.total_time, 0.2)
221
- assert_in_delta(0.0, thread.call_tree.target.self_time)
222
- assert_in_delta(0.0, thread.call_tree.target.wait_time)
223
- assert_in_delta(0.5, thread.call_tree.target.children_time, 0.2)
224
- end
225
- end
226
-
227
- def test_times_merge
228
- result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { concurrency }
229
- result.merge!
230
-
231
- assert_equal(2, result.threads.size)
232
-
233
- thread = result.threads[0]
234
- assert_in_delta(0.5, thread.call_tree.target.total_time, 0.2)
235
- assert_in_delta(0.0, thread.call_tree.target.self_time)
236
- assert_in_delta(0.0, thread.call_tree.target.wait_time)
237
- assert_in_delta(0.5, thread.call_tree.target.children_time, 0.2)
238
-
239
- thread = result.threads[1]
240
- assert_in_delta(1.5, thread.call_tree.target.total_time, 0.2)
241
- assert_in_delta(0.0, thread.call_tree.target.self_time)
242
- assert_in_delta(0.0, thread.call_tree.target.wait_time)
243
- assert_in_delta(1.5, thread.call_tree.target.children_time, 0.2)
244
- end
245
- end
246
195
  end
data/test/gc_test.rb CHANGED
@@ -37,7 +37,6 @@ class GcTest < TestCase
37
37
  end
38
38
  end
39
39
 
40
-
41
40
  def test_hold_onto_method
42
41
  methods = 5.times.reduce(Array.new) do |array, i|
43
42
  profile = run_profile
@@ -780,7 +780,7 @@ class MeasureProcessTimeTest < TestCase
780
780
  assert_in_delta(0.0, method.self_time, 0.05)
781
781
  assert_in_delta(0.0, method.children_time, 0.05)
782
782
  end
783
- else
783
+ else # Ruby 3.1 and higher
784
784
  def test_class_methods_sleep
785
785
  result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
786
786
  RubyProf::C1.sleep_wait
@@ -996,7 +996,8 @@ class MeasureProcessTimeTest < TestCase
996
996
  assert_in_delta(0.05, method.children_time, 0.05)
997
997
 
998
998
  method = methods[2]
999
- assert_equal('<Module::Process>#clock_gettime', method.full_name)
999
+ assert('<Module::Process>#clock_gettime' == method.full_name ||
1000
+ 'Float#<' == method.full_name)
1000
1001
  assert_in_delta(0.05, method.total_time, 0.05)
1001
1002
  assert_in_delta(0.0, method.wait_time, 0.05)
1002
1003
  assert_in_delta(0.05, method.self_time, 0.05)