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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +19 -0
  3. data/bin/ruby-prof +105 -87
  4. data/ext/ruby_prof/rp_allocation.c +136 -81
  5. data/ext/ruby_prof/rp_allocation.h +8 -6
  6. data/ext/ruby_prof/rp_call_tree.c +502 -457
  7. data/ext/ruby_prof/rp_call_tree.h +47 -44
  8. data/ext/ruby_prof/rp_call_trees.c +1 -1
  9. data/ext/ruby_prof/rp_measurement.c +10 -3
  10. data/ext/ruby_prof/rp_method.c +86 -79
  11. data/ext/ruby_prof/rp_method.h +63 -62
  12. data/ext/ruby_prof/rp_profile.c +933 -948
  13. data/ext/ruby_prof/rp_profile.h +1 -0
  14. data/ext/ruby_prof/rp_thread.c +433 -410
  15. data/ext/ruby_prof/rp_thread.h +39 -39
  16. data/ext/ruby_prof/vc/ruby_prof.vcxproj +6 -3
  17. data/lib/3.1/ruby_prof.so +0 -0
  18. data/lib/3.2/ruby_prof.so +0 -0
  19. data/lib/ruby-prof/compatibility.rb +14 -0
  20. data/lib/ruby-prof/printers/abstract_printer.rb +2 -1
  21. data/lib/ruby-prof/printers/call_tree_printer.rb +1 -1
  22. data/lib/ruby-prof/printers/multi_printer.rb +17 -17
  23. data/lib/ruby-prof/profile.rb +70 -70
  24. data/lib/ruby-prof/rack.rb +31 -21
  25. data/lib/ruby-prof/version.rb +1 -1
  26. data/test/abstract_printer_test.rb +1 -0
  27. data/test/alias_test.rb +6 -11
  28. data/test/call_tree_test.rb +94 -197
  29. data/test/call_tree_visitor_test.rb +1 -6
  30. data/test/call_trees_test.rb +2 -2
  31. data/test/{basic_test.rb → compatibility_test.rb} +8 -2
  32. data/test/duplicate_names_test.rb +1 -1
  33. data/test/dynamic_method_test.rb +1 -6
  34. data/test/enumerable_test.rb +1 -1
  35. data/test/exceptions_test.rb +2 -2
  36. data/test/exclude_methods_test.rb +3 -8
  37. data/test/exclude_threads_test.rb +4 -9
  38. data/test/fiber_test.rb +2 -58
  39. data/test/gc_test.rb +2 -2
  40. data/test/inverse_call_tree_test.rb +33 -34
  41. data/test/line_number_test.rb +1 -1
  42. data/test/marshal_test.rb +3 -3
  43. data/test/measure_allocations_test.rb +8 -17
  44. data/test/measure_memory_test.rb +3 -12
  45. data/test/measure_process_time_test.rb +32 -36
  46. data/test/measure_wall_time_test.rb +176 -181
  47. data/test/merge_test.rb +146 -0
  48. data/test/multi_printer_test.rb +0 -5
  49. data/test/no_method_class_test.rb +1 -1
  50. data/test/pause_resume_test.rb +12 -16
  51. data/test/printer_call_stack_test.rb +2 -2
  52. data/test/printer_call_tree_test.rb +2 -2
  53. data/test/printer_flat_test.rb +1 -1
  54. data/test/printer_graph_html_test.rb +2 -2
  55. data/test/printer_graph_test.rb +2 -2
  56. data/test/printers_test.rb +14 -20
  57. data/test/printing_recursive_graph_test.rb +2 -2
  58. data/test/recursive_test.rb +2 -7
  59. data/test/scheduler.rb +9 -0
  60. data/test/singleton_test.rb +1 -1
  61. data/test/stack_printer_test.rb +5 -8
  62. data/test/start_stop_test.rb +11 -14
  63. data/test/test_helper.rb +7 -0
  64. data/test/thread_test.rb +84 -19
  65. data/test/unique_call_path_test.rb +4 -4
  66. data/test/yarv_test.rb +3 -3
  67. 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
- assert_in_delta(11.6, thread_1.call_tree.total_time, 0.00001)
36
- assert_in_delta(0, thread_1.call_tree.self_time, 0.00001)
37
- assert_in_delta(0.0, thread_1.call_tree.wait_time, 0.00001)
38
- assert_in_delta(11.6, thread_1.call_tree.children_time, 0.00001)
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.start
104
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
105
+ thread = Thread.new do
106
+ sleep(1)
107
+ end
43
108
 
44
- thread = Thread.new do
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.start
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 = RubyProf.stop
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.start
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 = RubyProf.stop
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
- RubyProf::measure_mode = RubyProf::WALL_TIME
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.5.0
4
+ version: 1.6.2
5
5
  platform: x64-mingw-ucrt
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-02-07 00:00:00.000000000 Z
11
+ date: 2023-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -113,11 +113,11 @@ files:
113
113
  - ruby-prof.gemspec
114
114
  - test/abstract_printer_test.rb
115
115
  - test/alias_test.rb
116
- - test/basic_test.rb
117
116
  - test/call_tree_builder.rb
118
117
  - test/call_tree_test.rb
119
118
  - test/call_tree_visitor_test.rb
120
119
  - test/call_trees_test.rb
120
+ - test/compatibility_test.rb
121
121
  - test/duplicate_names_test.rb
122
122
  - test/dynamic_method_test.rb
123
123
  - test/enumerable_test.rb
@@ -136,6 +136,7 @@ files:
136
136
  - test/measure_times.rb
137
137
  - test/measure_wall_time_test.rb
138
138
  - test/measurement_test.rb
139
+ - test/merge_test.rb
139
140
  - test/method_info_test.rb
140
141
  - test/multi_printer_test.rb
141
142
  - test/no_method_class_test.rb
@@ -167,7 +168,7 @@ metadata:
167
168
  bug_tracker_uri: https://github.com/ruby-prof/ruby-prof/issues
168
169
  changelog_uri: https://github.com/ruby-prof/ruby-prof/blob/master/CHANGES
169
170
  documentation_uri: https://ruby-prof.github.io/
170
- source_code_uri: https://github.com/ruby-prof/ruby-prof/tree/v1.5.0
171
+ source_code_uri: https://github.com/ruby-prof/ruby-prof/tree/v1.6.2
171
172
  post_install_message:
172
173
  rdoc_options: []
173
174
  require_paths:
@@ -183,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
184
  - !ruby/object:Gem::Version
184
185
  version: '0'
185
186
  requirements: []
186
- rubygems_version: 3.4.6
187
+ rubygems_version: 3.4.8
187
188
  signing_key:
188
189
  specification_version: 4
189
190
  summary: Fast Ruby profiler