ruby-prof 1.6.1 → 1.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 382fb19115df1fa6e8ac2da32cea739768fceba7228e04cd3e72009185954545
4
- data.tar.gz: 4047e3e6f69c7a8b2750346837e264ae786185f07bd1aec666ecf6cd84a08c0f
3
+ metadata.gz: 416c147d8497f94d50b9b142596873a4f3bd5c9809bb5079f229fa413f626497
4
+ data.tar.gz: a7cceb2728e182181bac58ecd791a2d425be2e33c6ab1314a8fa66758a4d2ee1
5
5
  SHA512:
6
- metadata.gz: 41057a0f80b47b0477cd394c26bc693e6574e496b8d607004cbc0523f89f45b247569fe9af66e54c236ebc6025ff7636188b6314298db995c6d70ecda3ff5a5b
7
- data.tar.gz: 8df4a3e9dbc3fd82f65892e63a0c41f124d0c749e12b4fd120fb4bca42a4f09a5aac689f9906161e024aca9f495e75d47bf8d9fe7a9088fb1e7df5e305eb9e3f
6
+ metadata.gz: 754d7fd2b208eb398cbb5a3fb6830dc78f0164f0f0ee3024314587982a16a6329c9ae2b54f525d425ec13c2aac54209dfc97febc5920ca72b34aa9c8004c787d
7
+ data.tar.gz: 076c3bb65e7d71c036e8b393dd74ab51b6d4be4428998445e0c8af1e16f2ce384c36ba7a5417661933eb40d522dcee274a7040e26dd1a4eb2352a395e1fc8ed9
data/CHANGES CHANGED
@@ -1,3 +1,13 @@
1
+ 1.6.3 (2023-04-20)
2
+ =====================
3
+ * Remove debug code unintentionally left in ruby-prof command line program (Charlie Savage)
4
+
5
+ 1.6.2 (2023-04-17)
6
+ =====================
7
+ * Fix Profile#merge! implementation (asksurya)
8
+ * Fix ruby-prof command line program (Charlie Savage)
9
+ * Added CMakeLists.txt file (Charlie Savage)
10
+
1
11
  1.6.1 (2023-02-21)
2
12
  =====================
3
13
  * Fix loading C extension for MacOS (Charlie Savage)
data/bin/ruby-prof CHANGED
@@ -16,37 +16,38 @@ module RubyProf
16
16
  # ruby-prof [options] <script.rb> [--] [profiled-script-command-line-options]
17
17
  #
18
18
  # Options:
19
- # -p, --printer=printer Select a printer:
20
- # flat - Prints a flat profile as text (default).
21
- # graph - Prints a graph profile as text.
22
- # graph_html - Prints a graph profile as html.
23
- # call_tree - format for KCacheGrind
24
- # call_stack - prints a HTML visualization of the call tree
25
- # dot - Prints a graph profile as a dot file
26
- # multi - Creates several reports in output directory
19
+ # --allow_exceptions Raise exceptions encountered during profiling (true) or suppress them (false)
20
+ # -E, --eval-noprof=code execute the ruby statements (not profiled)
21
+ # --exclude=methods A comma separated list of methods to exclude.
22
+ # Specify instance methods via # (Integer#times)
23
+ # Specify class methods via . (Integer.superclass)
24
+ # --exclude-common Remove common methods from the profile
25
+ # -f, --file=path Output results to a file instead of standard out.
27
26
  # -m, --min_percent=min_percent The minimum percent a method must take before
28
27
  # being included in output reports.
29
28
  # This option is not supported for call tree.
30
- # -f, --file=path Output results to a file instead of standard out.
31
29
  # --mode=measure_mode Select what ruby-prof should measure:
32
30
  # wall - Wall time (default).
33
31
  # process - Process time.
34
32
  # allocations - Object allocations (requires patched Ruby interpreter).
35
33
  # memory - Allocated memory in KB (requires patched Ruby interpreter).
34
+ # -p, --printer=printer Select a printer:
35
+ # flat - Prints a flat profile as text (default).
36
+ # graph - Prints a graph profile as text.
37
+ # graph_html - Prints a graph profile as html.
38
+ # call_tree - format for KCacheGrind
39
+ # call_stack - prints a HTML visualization of the call tree
40
+ # dot - Prints a graph profile as a dot file
41
+ # multi - Creates several reports in output directory
42
+ # -R, --require-noprof=lib require a specific library (not profiled)
36
43
  # -s, --sort=sort_mode Select how ruby-prof results should be sorted:
37
44
  # total - Total time
38
45
  # self - Self time
39
46
  # wait - Wait time
40
47
  # child - Child time
41
- # --allow_exceptions Raise exceptions encountered during profiling (true) or suppress them (false)
42
- # -R, --require-noprof=lib require a specific library (not profiled)
43
- # -E, --eval-noprof=code execute the ruby statements (not profiled)
44
- # --exclude=methods A comma separated list of methods to exclude.
45
- # Specify instance methods via # (Integer#times)
46
- # Specify class methods via . (Integer.superclass)
47
- # --exclude-common Remove common methods from the profile
48
- # -h, --help Show help message
48
+ # --track_allocations Track allocations while profiling
49
49
  # -v, --version version Show version (1.1.0)
50
+ # -h, --help Show help message
50
51
 
51
52
  class Cmd
52
53
  # :enddoc:
@@ -63,15 +64,16 @@ module RubyProf
63
64
 
64
65
  def setup_options
65
66
  @options = OpenStruct.new
66
- options.printer = RubyProf::FlatPrinter
67
- options.measure_mode = RubyProf::WALL_TIME
68
- options.min_percent = 0
69
- options.file = nil
70
67
  options.allow_exceptions = false
71
- options.exclude_common = false
72
68
  options.exclude = Array.new
69
+ options.exclude_common = false
70
+ options.file = nil
71
+ options.measure_mode = RubyProf::WALL_TIME
72
+ options.min_percent = 0
73
73
  options.pre_libs = Array.new
74
74
  options.pre_execs = Array.new
75
+ options.printer = RubyProf::FlatPrinter
76
+ options.track_allocations = false
75
77
  end
76
78
 
77
79
  # This is copied from ActiveSupport:
@@ -118,40 +120,31 @@ module RubyProf
118
120
  opts.separator ""
119
121
  opts.separator "Options:"
120
122
 
121
- opts.on('-p printer', '--printer=printer', [:flat, :flat_with_line_numbers, :graph, :graph_html, :call_tree, :call_stack, :dot, :multi],
122
- 'Select a printer:',
123
- ' flat - Prints a flat profile as text (default).',
124
- ' graph - Prints a graph profile as text.',
125
- ' graph_html - Prints a graph profile as html.',
126
- ' call_tree - format for KCacheGrind',
127
- ' call_stack - prints a HTML visualization of the call tree',
128
- ' dot - Prints a graph profile as a dot file',
129
- ' multi - Creates several reports in output directory'
130
- ) do |printer|
123
+ opts.on('--allow_exceptions', 'Raise exceptions encountered during profiling (true) or suppress them (false)') do
124
+ options.allow_exceptions = true
125
+ end
131
126
 
132
- case printer
133
- when :flat
134
- options.printer = RubyProf::FlatPrinter
135
- when :graph
136
- options.printer = RubyProf::GraphPrinter
137
- when :graph_html
138
- options.printer = RubyProf::GraphHtmlPrinter
139
- when :call_tree
140
- options.printer = RubyProf::CallTreePrinter
141
- when :call_stack
142
- options.printer = RubyProf::CallStackPrinter
143
- when :dot
144
- options.printer = RubyProf::DotPrinter
145
- when :multi
146
- options.printer = RubyProf::MultiPrinter
127
+ opts.on('-E code', '--eval-noprof=code', 'execute the ruby statements (not profiled)') do |code|
128
+ options.pre_execs << code
129
+ end
130
+
131
+ opts.on('--exclude=methods', String,
132
+ 'A comma separated list of methods to exclude.',
133
+ ' Specify instance methods via # (Integer#times)',
134
+ ' Specify class methods via . (Integer.superclass)') do |exclude_string|
135
+ exclude_string.split(',').each do |string|
136
+ match = string.strip.match(/(.*)(#|\.)(.*)/)
137
+ klass = constantize(match[1])
138
+ if match[2] == '.'
139
+ klass = klass.singleton_class
140
+ end
141
+ method = match[3].to_sym
142
+ options.exclude << [klass, method]
147
143
  end
148
144
  end
149
145
 
150
- opts.on('-m min_percent', '--min_percent=min_percent', Float,
151
- 'The minimum percent a method must take before ',
152
- ' being included in output reports.',
153
- ' This option is not supported for call tree.') do |min_percent|
154
- options.min_percent = min_percent
146
+ opts.on('--exclude-common', 'Remove common methods from the profile') do
147
+ options.exclude_common = true
155
148
  end
156
149
 
157
150
  opts.on('-f path', '--file=path',
@@ -160,6 +153,13 @@ module RubyProf
160
153
  options.old_wd = Dir.pwd
161
154
  end
162
155
 
156
+ opts.on('-m min_percent', '--min_percent=min_percent', Float,
157
+ 'The minimum percent a method must take before ',
158
+ ' being included in output reports.',
159
+ ' This option is not supported for call tree.') do |min_percent|
160
+ options.min_percent = min_percent
161
+ end
162
+
163
163
  opts.on('--mode=measure_mode',
164
164
  [:process, :wall, :allocations, :memory],
165
165
  'Select what ruby-prof should measure:',
@@ -180,6 +180,39 @@ module RubyProf
180
180
  end
181
181
  end
182
182
 
183
+ opts.on('-p printer', '--printer=printer', [:flat, :flat_with_line_numbers, :graph, :graph_html, :call_tree, :call_stack, :dot, :multi],
184
+ 'Select a printer:',
185
+ ' flat - Prints a flat profile as text (default).',
186
+ ' graph - Prints a graph profile as text.',
187
+ ' graph_html - Prints a graph profile as html.',
188
+ ' call_tree - format for KCacheGrind',
189
+ ' call_stack - prints a HTML visualization of the call tree',
190
+ ' dot - Prints a graph profile as a dot file',
191
+ ' multi - Creates several reports in output directory'
192
+ ) do |printer|
193
+
194
+ case printer
195
+ when :flat
196
+ options.printer = RubyProf::FlatPrinter
197
+ when :graph
198
+ options.printer = RubyProf::GraphPrinter
199
+ when :graph_html
200
+ options.printer = RubyProf::GraphHtmlPrinter
201
+ when :call_tree
202
+ options.printer = RubyProf::CallTreePrinter
203
+ when :call_stack
204
+ options.printer = RubyProf::CallStackPrinter
205
+ when :dot
206
+ options.printer = RubyProf::DotPrinter
207
+ when :multi
208
+ options.printer = RubyProf::MultiPrinter
209
+ end
210
+ end
211
+
212
+ opts.on('-R lib', '--require-noprof=lib', 'require a specific library (not profiled)') do |lib|
213
+ options.pre_libs << lib
214
+ end
215
+
183
216
  opts.on('-s sort_mode', '--sort=sort_mode', [:total, :self, :wait, :child],
184
217
  'Select how ruby-prof results should be sorted:',
185
218
  ' total - Total time',
@@ -199,9 +232,8 @@ module RubyProf
199
232
  end
200
233
  end
201
234
 
202
- opts.on_tail("-h", "--help", "Show help message") do
203
- puts opts
204
- exit
235
+ opts.on('--track_allocations', 'Track allocations while profiling') do
236
+ options.track_allocations = true
205
237
  end
206
238
 
207
239
  opts.on_tail("-v version", "--version", "Show version (#{RubyProf::VERSION})") do
@@ -209,35 +241,9 @@ module RubyProf
209
241
  exit
210
242
  end
211
243
 
212
- opts.on('--allow_exceptions', 'Raise exceptions encountered during profiling (true) or suppress them (false)') do
213
- options.allow_exceptions = true
214
- end
215
-
216
- opts.on('-R lib', '--require-noprof=lib', 'require a specific library (not profiled)') do |lib|
217
- options.pre_libs << lib
218
- end
219
-
220
- opts.on('-E code', '--eval-noprof=code', 'execute the ruby statements (not profiled)') do |code|
221
- options.pre_execs << code
222
- end
223
-
224
- opts.on('--exclude=methods', String,
225
- 'A comma separated list of methods to exclude.',
226
- ' Specify instance methods via # (Integer#times)',
227
- ' Specify class methods via . (Integer.superclass)') do |exclude_string|
228
- exclude_string.split(',').each do |string|
229
- match = string.strip.match(/(.*)(#|\.)(.*)/)
230
- klass = constantize(match[1])
231
- if match[2] == '.'
232
- klass = klass.singleton_class
233
- end
234
- method = match[3].to_sym
235
- options.exclude << [klass, method]
236
- end
237
- end
238
-
239
- opts.on('--exclude-common', 'Remove common methods from the profile') do
240
- options.exclude_common = true
244
+ opts.on_tail("-h", "--help", "Show help message") do
245
+ puts opts
246
+ exit
241
247
  end
242
248
  end
243
249
  end
@@ -281,12 +287,18 @@ module RubyProf
281
287
  end
282
288
 
283
289
  def run
284
- script = ARGV.shift
285
- @profile = Profile.new(options.to_h)
290
+ profile_options = {:allow_exceptions => options.allow_exceptions,
291
+ :exclude_common => options.exclude_common,
292
+ :measure_mode => options.measure_mode,
293
+ :track_allocations => options.track_allocations}
294
+
295
+ @profile = Profile.new(**profile_options)
296
+
286
297
  options.exclude.each do |klass, method|
287
298
  @profile.exclude_method!(klass, method)
288
299
  end
289
300
 
301
+ script = ARGV.shift
290
302
  profile.profile do
291
303
  load script
292
304
  end
@@ -304,7 +316,8 @@ cmd = RubyProf::Cmd.new
304
316
  at_exit {
305
317
  # Create a printer
306
318
  printer = cmd.options.printer.new(cmd.profile)
307
- printer_options = {:min_percent => cmd.options.min_percent, :sort_method => cmd.options.sort_method}
319
+ printer_options = {:min_percent => cmd.options.min_percent,
320
+ :sort_method => cmd.options.sort_method}
308
321
 
309
322
  # Get output
310
323
  if cmd.options.file