ruby-prof 1.6.2-x64-mingw-ucrt → 1.7.0-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +11 -0
  3. data/bin/ruby-prof +0 -5
  4. data/ext/ruby_prof/rp_allocation.c +342 -342
  5. data/ext/ruby_prof/rp_call_tree.c +1 -1
  6. data/ext/ruby_prof/rp_call_tree.h +1 -1
  7. data/ext/ruby_prof/rp_call_trees.c +2 -2
  8. data/ext/ruby_prof/rp_call_trees.h +2 -2
  9. data/ext/ruby_prof/rp_measure_allocations.c +1 -1
  10. data/ext/ruby_prof/rp_measure_memory.c +46 -46
  11. data/ext/ruby_prof/rp_measure_process_time.c +1 -1
  12. data/ext/ruby_prof/rp_measure_wall_time.c +1 -1
  13. data/ext/ruby_prof/rp_measurement.c +364 -364
  14. data/ext/ruby_prof/rp_method.c +24 -12
  15. data/ext/ruby_prof/rp_method.h +5 -2
  16. data/ext/ruby_prof/rp_profile.c +2 -2
  17. data/ext/ruby_prof/rp_profile.h +36 -36
  18. data/ext/ruby_prof/rp_stack.c +1 -1
  19. data/ext/ruby_prof/rp_thread.c +1 -1
  20. data/ext/ruby_prof/ruby_prof.c +1 -1
  21. data/ext/ruby_prof/ruby_prof.h +34 -34
  22. data/ext/ruby_prof/vc/ruby_prof.vcxproj +5 -7
  23. data/lib/3.2/ruby_prof.so +0 -0
  24. data/lib/3.3/ruby_prof.so +0 -0
  25. data/lib/ruby-prof/compatibility.rb +10 -10
  26. data/lib/ruby-prof/exclude_common_methods.rb +9 -3
  27. data/lib/ruby-prof/method_info.rb +87 -85
  28. data/lib/ruby-prof/version.rb +1 -1
  29. data/ruby-prof.gemspec +1 -1
  30. data/test/crash2.rb +144 -0
  31. data/test/enumerable_test.rb +5 -5
  32. data/test/exclude_methods_test.rb +197 -86
  33. data/test/line_number_test.rb +254 -99
  34. data/test/measure_allocations_test.rb +422 -1
  35. data/test/measure_memory_test.rb +433 -1
  36. data/test/measure_process_time_test.rb +882 -15
  37. data/test/measure_wall_time_test.rb +195 -47
  38. data/test/method_info_test.rb +1 -1
  39. data/test/recursive_test.rb +198 -1
  40. data/test/thread_test.rb +0 -4
  41. metadata +7 -6
  42. data/lib/3.1/ruby_prof.so +0 -0
data/test/crash2.rb ADDED
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # This is a benchmark for HTTPS traffic.
5
+ # To run against a local server:
6
+ # docker run --rm --detach --name httpbin -v /tmp:/tmp -v $PWD/tests/data:/data -e HTTPS_CERT_FILE='/data/127.0.0.1.cert.crt' -e HTTPS_KEY_FILE='/data/127.0.0.1.cert.key' -e PORT='8443' -p 8443:8443 mccutchen/go-httpbin
7
+ # Then, run the benchmark:
8
+ # benchmarks/httpbin.rb --uri='https://localhost:8443/stream-bytes/102400?chunk_size=1024'
9
+ # Finally, stop the server with:
10
+ # docker kill httpbin
11
+
12
+ #require 'bundler/inline'
13
+
14
+ #gemfile do
15
+ # source 'https://rubygems.org'
16
+
17
+ # gem 'benchmark-ips', require: 'benchmark/ips'
18
+ # gem 'ruby-prof', '1.6.3'
19
+ # gem 'excon'
20
+ #end
21
+
22
+ require File.expand_path('../test_helper', __FILE__)
23
+
24
+
25
+ require 'openssl'
26
+ require 'optparse'
27
+ require 'uri'
28
+ require 'excon'
29
+ require 'benchmark'
30
+ require 'benchmark/ips'
31
+
32
+ Options = Struct.new(:uri, :profile, :time, :warmup, :iterations, :status)
33
+
34
+ options = Options.new(
35
+ URI.parse('https://httpbingo.org/stream-bytes/102400?chunk_size=1024'),
36
+ false,
37
+ 10,
38
+ 5,
39
+ 2,
40
+ 200
41
+ )
42
+
43
+ OptionParser.new do |opts|
44
+ opts.banner = "Usage: ruby #{__FILE__} [options]"
45
+
46
+ opts.on('-u URI', '--uri=URI', String, "URI to send requests to (default: #{options.uri})") do |uri|
47
+ options.uri = URI.parse(uri)
48
+ end
49
+
50
+ opts.on('-p', '--[no-]profile', 'Profile the benchmark using Ruby-Prof (defaults to no profiling)') do |profile|
51
+ options.profile = profile
52
+ end
53
+
54
+ opts.on('-t TIME', '--time=TIME', Float, "The number of seconds to run the benchmark to measure performance (default: #{options.time})") do |time|
55
+ options.time = time
56
+ end
57
+
58
+ opts.on('-w WARMUP', '--warmup=WARMUP', Float, "The number of seconds to warmup the benchmark for before measuring (default: #{options.warmup})") do |warmup|
59
+ options.warmup = warmup
60
+ end
61
+
62
+ opts.on('-i ITERATIONS', '--iterations=ITERATIONS', Integer, "The number of iterations to run the benchmark for (default: #{options.iterations})") do |iterations|
63
+ options.iterations = iterations
64
+ end
65
+
66
+ opts.on('-s STATUS', '--status=STATUS', Integer, "The HTTP status expected from a request to the given URI (default: #{options.status})") do |status|
67
+ options.status = status
68
+ end
69
+
70
+ opts.on('-h', '--help', 'print options') do
71
+ puts opts
72
+ exit
73
+ end
74
+ end.parse!
75
+
76
+ # Enable and start GC before each job run. Disable GC afterwards.
77
+ #
78
+ # Inspired by https://www.omniref.com/ruby/2.2.1/symbols/Benchmark/bm?#annotation=4095926&line=182
79
+ class GCSuite
80
+ def warming(*)
81
+ run_gc
82
+ end
83
+
84
+ def running(*)
85
+ run_gc
86
+ end
87
+
88
+ def warmup_stats(*); end
89
+
90
+ def add_report(*); end
91
+
92
+ private
93
+
94
+ def run_gc
95
+ GC.enable
96
+ GC.start
97
+ GC.compact
98
+ GC.disable
99
+ end
100
+ end
101
+
102
+ profile = nil
103
+
104
+ if options.profile
105
+ profile = RubyProf::Profile.new(track_allocations: true, measure_mode: RubyProf::MEMORY)
106
+ profile.start
107
+ profile.pause
108
+ end
109
+
110
+ excerpt = ['Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.']
111
+ data = (excerpt * 3).join(' ')
112
+
113
+ client = ::Excon.new(options.uri.to_s, ssl_verify_peer: false, ssl_verify_peer_host: false, persistent: true, retry_errors: [Excon::Error::Socket], idempotent: true)
114
+
115
+ Benchmark.ips do |x|
116
+ x.time = options.time
117
+ x.warmup = options.warmup
118
+ x.suite = GCSuite.new
119
+ x.iterations = options.iterations
120
+
121
+ x.report(options.uri.to_s) do
122
+ profile&.resume
123
+
124
+ response = client.request(method: :get, headers: { data: data })
125
+
126
+ response.body
127
+ response.status
128
+
129
+ profile&.pause
130
+
131
+ raise "Invalid status: expected #{options.status}, actual is #{response.status}" unless response.status == options.status
132
+ end
133
+
134
+ x.compare!
135
+ end
136
+
137
+ if options.profile
138
+ result = profile.stop
139
+
140
+ File.open("excon-#{Excon::VERSION}.html", 'w') do |output|
141
+ printer = RubyProf::GraphHtmlPrinter.new(result)
142
+ printer.print(output)
143
+ end
144
+ end
@@ -11,11 +11,11 @@ class EnumerableTest < TestCase
11
11
  result = RubyProf::Profile.profile do
12
12
  3.times { [1,2,3].any? {|n| n} }
13
13
  end
14
- methods = if RUBY_VERSION >= "2.2.0"
15
- %w(EnumerableTest#test_enumerable Integer#times Array#any?)
16
- else
17
- %w(EnumerableTest#test_enumerable Integer#times Enumerable#any? Array#each)
18
- end
14
+ methods = if RUBY_VERSION >= "3.3.0"
15
+ %w(EnumerableTest#test_enumerable Integer#times Kernel#block_given? Integer#< Array#any? Integer#succ)
16
+ else
17
+ %w(EnumerableTest#test_enumerable Integer#times Array#any?)
18
+ end
19
19
  assert_equal(methods, result.threads.first.methods.map(&:full_name))
20
20
  end
21
21
  end
@@ -34,98 +34,209 @@ class ExcludeMethodsClass
34
34
  end
35
35
 
36
36
  class ExcludeMethodsTest < TestCase
37
- def test_methods_can_be_profiled
38
- obj = ExcludeMethodsClass.new
39
- prf = RubyProf::Profile.new(measure_mode: RubyProf::WALL_TIME)
40
-
41
- result = prf.profile {obj.a}
42
- methods = result.threads.first.methods.sort.reverse
43
- assert_equal(10, methods.count)
44
- assert_equal('ExcludeMethodsTest#test_methods_can_be_profiled', methods[0].full_name)
45
- assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
46
- assert_equal('Integer#times', methods[2].full_name)
47
- assert_equal('ExcludeMethodsClass#b', methods[3].full_name)
48
- assert_equal('<Class::ExcludeMethodsClass>#e', methods[4].full_name)
49
- assert_equal('<Class::ExcludeMethodsClass>#f', methods[5].full_name)
50
- assert_equal('Kernel#sleep', methods[6].full_name)
51
- assert_equal('ExcludeMethodsModule#c', methods[7].full_name)
52
- assert_equal('<Module::ExcludeMethodsModule>#d', methods[8].full_name)
53
- assert_equal('Kernel#class', methods[9].full_name)
54
- end
37
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.3')
38
+ def test_methods_can_be_profiled
39
+ obj = ExcludeMethodsClass.new
40
+ prf = RubyProf::Profile.new(measure_mode: RubyProf::WALL_TIME)
55
41
 
56
- def test_methods_can_be_hidden1
57
- obj = ExcludeMethodsClass.new
58
- prf = RubyProf::Profile.new
59
-
60
- prf.exclude_methods!(Integer, :times)
61
-
62
- result = prf.profile {obj.a}
63
- methods = result.threads.first.methods.sort.reverse
64
-
65
- assert_equal(9, methods.count)
66
- assert_equal('ExcludeMethodsTest#test_methods_can_be_hidden1', methods[0].full_name)
67
- assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
68
- assert_equal('ExcludeMethodsClass#b', methods[2].full_name)
69
- assert_equal('<Class::ExcludeMethodsClass>#e', methods[3].full_name)
70
- assert_equal('<Class::ExcludeMethodsClass>#f', methods[4].full_name)
71
- assert_equal('Kernel#sleep', methods[5].full_name)
72
- assert_equal('ExcludeMethodsModule#c', methods[6].full_name)
73
- assert_equal('<Module::ExcludeMethodsModule>#d', methods[7].full_name)
74
- assert_equal('Kernel#class', methods[8].full_name)
75
- end
42
+ result = prf.profile {obj.a}
43
+ methods = result.threads.first.methods.sort.reverse
44
+ assert_equal(10, methods.count)
45
+ assert_equal('ExcludeMethodsTest#test_methods_can_be_profiled', methods[0].full_name)
46
+ assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
47
+ assert_equal('Integer#times', methods[2].full_name)
48
+ assert_equal('ExcludeMethodsClass#b', methods[3].full_name)
49
+ assert_equal('<Class::ExcludeMethodsClass>#e', methods[4].full_name)
50
+ assert_equal('<Class::ExcludeMethodsClass>#f', methods[5].full_name)
51
+ assert_equal('Kernel#sleep', methods[6].full_name)
52
+ assert_equal('ExcludeMethodsModule#c', methods[7].full_name)
53
+ assert_equal('<Module::ExcludeMethodsModule>#d', methods[8].full_name)
54
+ assert_equal('Kernel#class', methods[9].full_name)
55
+ end
76
56
 
77
- def test_methods_can_be_hidden2
78
- obj = ExcludeMethodsClass.new
79
- prf = RubyProf::Profile.new
80
-
81
- prf.exclude_methods!(Integer, :times)
82
- prf.exclude_methods!(ExcludeMethodsClass.singleton_class, :f)
83
- prf.exclude_methods!(ExcludeMethodsModule.singleton_class, :d)
84
-
85
- result = prf.profile {obj.a}
86
- methods = result.threads.first.methods.sort.reverse
87
-
88
- assert_equal(7, methods.count)
89
- assert_equal('ExcludeMethodsTest#test_methods_can_be_hidden2', methods[0].full_name)
90
- assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
91
- assert_equal('ExcludeMethodsClass#b', methods[2].full_name)
92
- assert_equal('<Class::ExcludeMethodsClass>#e', methods[3].full_name)
93
- assert_equal('Kernel#sleep', methods[4].full_name)
94
- assert_equal('ExcludeMethodsModule#c', methods[5].full_name)
95
- assert_equal('Kernel#class', methods[6].full_name)
96
- end
57
+ def test_methods_can_be_hidden1
58
+ obj = ExcludeMethodsClass.new
59
+ prf = RubyProf::Profile.new
97
60
 
98
- def test_exclude_common_methods1
99
- obj = ExcludeMethodsClass.new
100
- prf = RubyProf::Profile.new(measure_mode: RubyProf::WALL_TIME)
101
-
102
- prf.exclude_common_methods!
103
-
104
- result = prf.profile {obj.a}
105
- methods = result.threads.first.methods.sort.reverse
106
-
107
- assert_equal(9, methods.count)
108
- assert_equal('ExcludeMethodsTest#test_exclude_common_methods1', methods[0].full_name)
109
- assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
110
- assert_equal('ExcludeMethodsClass#b', methods[2].full_name)
111
- assert_equal('<Class::ExcludeMethodsClass>#e', methods[3].full_name)
112
- assert_equal('<Class::ExcludeMethodsClass>#f', methods[4].full_name)
113
- assert_equal('Kernel#sleep', methods[5].full_name)
114
- assert_equal('ExcludeMethodsModule#c', methods[6].full_name)
115
- assert_equal('<Module::ExcludeMethodsModule>#d', methods[7].full_name)
116
- assert_equal('Kernel#class', methods[8].full_name)
117
- end
61
+ prf.exclude_methods!(Integer, :times)
62
+
63
+ result = prf.profile {obj.a}
64
+ methods = result.threads.first.methods.sort.reverse
65
+
66
+ assert_equal(9, methods.count)
67
+ assert_equal('ExcludeMethodsTest#test_methods_can_be_hidden1', methods[0].full_name)
68
+ assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
69
+ assert_equal('ExcludeMethodsClass#b', methods[2].full_name)
70
+ assert_equal('<Class::ExcludeMethodsClass>#e', methods[3].full_name)
71
+ assert_equal('<Class::ExcludeMethodsClass>#f', methods[4].full_name)
72
+ assert_equal('Kernel#sleep', methods[5].full_name)
73
+ assert_equal('ExcludeMethodsModule#c', methods[6].full_name)
74
+ assert_equal('<Module::ExcludeMethodsModule>#d', methods[7].full_name)
75
+ assert_equal('Kernel#class', methods[8].full_name)
76
+ end
77
+
78
+ def test_methods_can_be_hidden2
79
+ obj = ExcludeMethodsClass.new
80
+ prf = RubyProf::Profile.new
81
+
82
+ prf.exclude_methods!(Integer, :times)
83
+ prf.exclude_methods!(ExcludeMethodsClass.singleton_class, :f)
84
+ prf.exclude_methods!(ExcludeMethodsModule.singleton_class, :d)
85
+
86
+ result = prf.profile {obj.a}
87
+ methods = result.threads.first.methods.sort.reverse
88
+
89
+ assert_equal(7, methods.count)
90
+ assert_equal('ExcludeMethodsTest#test_methods_can_be_hidden2', methods[0].full_name)
91
+ assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
92
+ assert_equal('ExcludeMethodsClass#b', methods[2].full_name)
93
+ assert_equal('<Class::ExcludeMethodsClass>#e', methods[3].full_name)
94
+ assert_equal('Kernel#sleep', methods[4].full_name)
95
+ assert_equal('ExcludeMethodsModule#c', methods[5].full_name)
96
+ assert_equal('Kernel#class', methods[6].full_name)
97
+ end
98
+
99
+ def test_exclude_common_methods1
100
+ obj = ExcludeMethodsClass.new
101
+ prf = RubyProf::Profile.new(measure_mode: RubyProf::WALL_TIME)
102
+
103
+ prf.exclude_common_methods!
104
+
105
+ result = prf.profile {obj.a}
106
+ methods = result.threads.first.methods.sort.reverse
107
+
108
+ assert_equal(9, methods.count)
109
+ assert_equal('ExcludeMethodsTest#test_exclude_common_methods1', methods[0].full_name)
110
+ assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
111
+ assert_equal('ExcludeMethodsClass#b', methods[2].full_name)
112
+ assert_equal('<Class::ExcludeMethodsClass>#e', methods[3].full_name)
113
+ assert_equal('<Class::ExcludeMethodsClass>#f', methods[4].full_name)
114
+ assert_equal('Kernel#sleep', methods[5].full_name)
115
+ assert_equal('ExcludeMethodsModule#c', methods[6].full_name)
116
+ assert_equal('<Module::ExcludeMethodsModule>#d', methods[7].full_name)
117
+ assert_equal('Kernel#class', methods[8].full_name)
118
+ end
119
+
120
+ def test_exclude_common_methods2
121
+ obj = ExcludeMethodsClass.new
122
+
123
+ result = RubyProf::Profile.profile(exclude_common: true) { 5.times {obj.a} }
124
+ methods = result.threads.first.methods.sort.reverse
118
125
 
119
- def test_exclude_common_methods2
120
- obj = ExcludeMethodsClass.new
126
+ assert_equal(9, methods.count)
127
+ assert_equal('ExcludeMethodsTest#test_exclude_common_methods2', methods[0].full_name)
128
+ assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
129
+ assert_equal('ExcludeMethodsClass#b', methods[2].full_name)
130
+ end
131
+ else
132
+ def test_methods_can_be_profiled
133
+ obj = ExcludeMethodsClass.new
134
+ prf = RubyProf::Profile.new(measure_mode: RubyProf::WALL_TIME)
135
+
136
+ result = prf.profile {obj.a}
137
+ methods = result.threads.first.methods.sort.reverse
138
+ assert_equal(13, methods.count)
139
+ assert_equal('ExcludeMethodsTest#test_methods_can_be_profiled', methods[0].full_name)
140
+ assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
141
+ assert_equal('Integer#times', methods[2].full_name)
142
+ assert_equal('ExcludeMethodsClass#b', methods[3].full_name)
143
+ assert_equal('<Class::ExcludeMethodsClass>#e', methods[4].full_name)
144
+ assert_equal('<Class::ExcludeMethodsClass>#f', methods[5].full_name)
145
+ assert_equal('Kernel#sleep', methods[6].full_name)
146
+ assert_equal('ExcludeMethodsModule#c', methods[7].full_name)
147
+ assert_equal('<Module::ExcludeMethodsModule>#d', methods[8].full_name)
148
+ assert_equal('Kernel#block_given?', methods[9].full_name)
149
+ assert_equal('Integer#succ', methods[10].full_name)
150
+ assert_equal('Integer#<', methods[11].full_name)
151
+ assert_equal('Kernel#class', methods[12].full_name)
152
+ end
153
+
154
+ def test_methods_can_be_hidden1
155
+ obj = ExcludeMethodsClass.new
156
+ prf = RubyProf::Profile.new
157
+
158
+ prf.exclude_methods!(Integer, :times)
159
+
160
+ result = prf.profile {obj.a}
161
+ methods = result.threads.first.methods.sort.reverse
162
+
163
+ assert_equal(12, methods.count)
164
+ assert_equal('ExcludeMethodsTest#test_methods_can_be_hidden1', methods[0].full_name)
165
+ assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
166
+ assert_equal('ExcludeMethodsClass#b', methods[2].full_name)
167
+ assert_equal('<Class::ExcludeMethodsClass>#e', methods[3].full_name)
168
+ assert_equal('<Class::ExcludeMethodsClass>#f', methods[4].full_name)
169
+ assert_equal('Kernel#sleep', methods[5].full_name)
170
+ assert_equal('ExcludeMethodsModule#c', methods[6].full_name)
171
+ assert_equal('<Module::ExcludeMethodsModule>#d', methods[7].full_name)
172
+ assert_equal('Kernel#block_given?', methods[8].full_name)
173
+ assert_equal('Integer#succ', methods[9].full_name)
174
+ assert_equal('Integer#<', methods[10].full_name)
175
+ assert_equal('Kernel#class', methods[11].full_name)
176
+ end
177
+
178
+ def test_methods_can_be_hidden2
179
+ obj = ExcludeMethodsClass.new
180
+ prf = RubyProf::Profile.new
181
+
182
+ prf.exclude_methods!(Integer, :times)
183
+ prf.exclude_methods!(ExcludeMethodsClass.singleton_class, :f)
184
+ prf.exclude_methods!(ExcludeMethodsModule.singleton_class, :d)
121
185
 
122
- result = RubyProf::Profile.profile(exclude_common: true) { 5.times {obj.a} }
123
- methods = result.threads.first.methods.sort.reverse
186
+ result = prf.profile {obj.a}
187
+ methods = result.threads.first.methods.sort.reverse
124
188
 
125
- assert_equal(9, methods.count)
126
- assert_equal('ExcludeMethodsTest#test_exclude_common_methods2', methods[0].full_name)
127
- assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
128
- assert_equal('ExcludeMethodsClass#b', methods[2].full_name)
189
+ assert_equal(10, methods.count)
190
+ assert_equal('ExcludeMethodsTest#test_methods_can_be_hidden2', methods[0].full_name)
191
+ assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
192
+ assert_equal('ExcludeMethodsClass#b', methods[2].full_name)
193
+ assert_equal('<Class::ExcludeMethodsClass>#e', methods[3].full_name)
194
+ assert_equal('Kernel#sleep', methods[4].full_name)
195
+ assert_equal('ExcludeMethodsModule#c', methods[5].full_name)
196
+ assert_equal('Kernel#block_given?', methods[6].full_name)
197
+ assert_equal('Integer#succ', methods[7].full_name)
198
+ assert_equal('Integer#<', methods[8].full_name)
199
+ assert_equal('Kernel#class', methods[9].full_name)
200
+ end
201
+
202
+ def test_exclude_common_methods1
203
+ obj = ExcludeMethodsClass.new
204
+ prf = RubyProf::Profile.new(measure_mode: RubyProf::WALL_TIME)
205
+
206
+ prf.exclude_common_methods!
207
+
208
+ result = prf.profile {obj.a}
209
+ methods = result.threads.first.methods.sort.reverse
210
+
211
+ assert_equal(9, methods.count)
212
+ assert_equal('ExcludeMethodsTest#test_exclude_common_methods1', methods[0].full_name)
213
+ assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
214
+ assert_equal('ExcludeMethodsClass#b', methods[2].full_name)
215
+ assert_equal('<Class::ExcludeMethodsClass>#e', methods[3].full_name)
216
+ assert_equal('<Class::ExcludeMethodsClass>#f', methods[4].full_name)
217
+ assert_equal('Kernel#sleep', methods[5].full_name)
218
+ assert_equal('ExcludeMethodsModule#c', methods[6].full_name)
219
+ assert_equal('<Module::ExcludeMethodsModule>#d', methods[7].full_name)
220
+ assert_equal('Kernel#class', methods[8].full_name)
221
+ end
222
+
223
+ def test_exclude_common_methods2
224
+ obj = ExcludeMethodsClass.new
225
+
226
+ result = RubyProf::Profile.profile(exclude_common: true) { 5.times {obj.a} }
227
+ methods = result.threads.first.methods.sort.reverse
228
+
229
+ assert_equal(9, methods.count)
230
+ assert_equal('ExcludeMethodsTest#test_exclude_common_methods2', methods[0].full_name)
231
+ assert_equal('ExcludeMethodsClass#a', methods[1].full_name)
232
+ assert_equal('ExcludeMethodsClass#b', methods[2].full_name)
233
+ assert_equal('<Class::ExcludeMethodsClass>#e', methods[3].full_name)
234
+ assert_equal('<Class::ExcludeMethodsClass>#f', methods[4].full_name)
235
+ assert_equal('Kernel#sleep', methods[5].full_name)
236
+ assert_equal('ExcludeMethodsModule#c', methods[6].full_name)
237
+ assert_equal('<Module::ExcludeMethodsModule>#d', methods[7].full_name)
238
+ assert_equal('Kernel#class', methods[8].full_name)
239
+ end
129
240
  end
130
241
 
131
242
  private