ruby-prof 1.1.0-x64-mingw32 → 1.4.2-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +48 -1
  3. data/Rakefile +2 -14
  4. data/bin/ruby-prof +100 -152
  5. data/ext/ruby_prof/extconf.rb +8 -28
  6. data/ext/ruby_prof/rp_aggregate_call_tree.c +59 -0
  7. data/ext/ruby_prof/rp_aggregate_call_tree.h +13 -0
  8. data/ext/ruby_prof/rp_allocation.c +67 -59
  9. data/ext/ruby_prof/rp_allocation.h +3 -3
  10. data/ext/ruby_prof/rp_call_tree.c +369 -0
  11. data/ext/ruby_prof/rp_call_tree.h +43 -0
  12. data/ext/ruby_prof/rp_call_trees.c +288 -0
  13. data/ext/ruby_prof/rp_call_trees.h +28 -0
  14. data/ext/ruby_prof/rp_measure_allocations.c +12 -14
  15. data/ext/ruby_prof/rp_measure_process_time.c +12 -14
  16. data/ext/ruby_prof/rp_measure_wall_time.c +17 -15
  17. data/ext/ruby_prof/rp_measurement.c +47 -40
  18. data/ext/ruby_prof/rp_measurement.h +7 -7
  19. data/ext/ruby_prof/rp_method.c +116 -255
  20. data/ext/ruby_prof/rp_method.h +31 -39
  21. data/ext/ruby_prof/rp_profile.c +316 -303
  22. data/ext/ruby_prof/rp_profile.h +1 -3
  23. data/ext/ruby_prof/rp_stack.c +122 -106
  24. data/ext/ruby_prof/rp_stack.h +17 -20
  25. data/ext/ruby_prof/rp_thread.c +136 -111
  26. data/ext/ruby_prof/rp_thread.h +12 -9
  27. data/ext/ruby_prof/ruby_prof.c +27 -23
  28. data/ext/ruby_prof/ruby_prof.h +9 -0
  29. data/ext/ruby_prof/vc/ruby_prof.sln +8 -0
  30. data/ext/ruby_prof/vc/ruby_prof.vcxproj +22 -7
  31. data/lib/2.7/ruby_prof.so +0 -0
  32. data/lib/ruby-prof.rb +5 -5
  33. data/lib/ruby-prof/assets/call_stack_printer.html.erb +4 -7
  34. data/lib/ruby-prof/assets/graph_printer.html.erb +5 -6
  35. data/lib/ruby-prof/{call_info.rb → call_tree.rb} +6 -6
  36. data/lib/ruby-prof/call_tree_visitor.rb +36 -0
  37. data/lib/ruby-prof/compatibility.rb +0 -10
  38. data/lib/ruby-prof/measurement.rb +5 -2
  39. data/lib/ruby-prof/method_info.rb +3 -15
  40. data/lib/ruby-prof/printers/abstract_printer.rb +12 -2
  41. data/lib/ruby-prof/printers/call_info_printer.rb +12 -10
  42. data/lib/ruby-prof/printers/call_stack_printer.rb +20 -22
  43. data/lib/ruby-prof/printers/call_tree_printer.rb +1 -1
  44. data/lib/ruby-prof/printers/dot_printer.rb +3 -3
  45. data/lib/ruby-prof/printers/flat_printer.rb +3 -2
  46. data/lib/ruby-prof/printers/graph_printer.rb +4 -5
  47. data/lib/ruby-prof/printers/multi_printer.rb +2 -2
  48. data/lib/ruby-prof/profile.rb +8 -4
  49. data/lib/ruby-prof/rack.rb +51 -127
  50. data/lib/ruby-prof/thread.rb +3 -18
  51. data/lib/ruby-prof/version.rb +1 -1
  52. data/ruby-prof.gemspec +7 -0
  53. data/test/alias_test.rb +42 -45
  54. data/test/basic_test.rb +0 -86
  55. data/test/{call_info_visitor_test.rb → call_tree_visitor_test.rb} +6 -5
  56. data/test/call_trees_test.rb +66 -0
  57. data/test/exclude_methods_test.rb +17 -12
  58. data/test/fiber_test.rb +95 -39
  59. data/test/gc_test.rb +36 -42
  60. data/test/inverse_call_tree_test.rb +175 -0
  61. data/test/line_number_test.rb +67 -70
  62. data/test/marshal_test.rb +7 -13
  63. data/test/measure_allocations_test.rb +224 -234
  64. data/test/measure_allocations_trace_test.rb +224 -234
  65. data/test/measure_memory_trace_test.rb +814 -469
  66. data/test/measure_process_time_test.rb +0 -64
  67. data/test/measure_times.rb +2 -0
  68. data/test/measure_wall_time_test.rb +34 -58
  69. data/test/pause_resume_test.rb +19 -10
  70. data/test/prime.rb +1 -3
  71. data/test/prime_script.rb +6 -0
  72. data/test/printer_call_stack_test.rb +0 -1
  73. data/test/printer_call_tree_test.rb +0 -1
  74. data/test/printer_flat_test.rb +61 -30
  75. data/test/printer_graph_html_test.rb +0 -1
  76. data/test/printer_graph_test.rb +3 -4
  77. data/test/printers_test.rb +2 -2
  78. data/test/printing_recursive_graph_test.rb +1 -1
  79. data/test/profile_test.rb +16 -0
  80. data/test/rack_test.rb +0 -64
  81. data/test/recursive_test.rb +50 -54
  82. data/test/start_stop_test.rb +19 -19
  83. data/test/test_helper.rb +6 -17
  84. data/test/thread_test.rb +11 -11
  85. data/test/unique_call_path_test.rb +25 -95
  86. metadata +22 -11
  87. data/ext/ruby_prof/rp_call_info.c +0 -271
  88. data/ext/ruby_prof/rp_call_info.h +0 -35
  89. data/lib/2.6.5/ruby_prof.so +0 -0
  90. data/lib/ruby-prof/call_info_visitor.rb +0 -38
  91. data/test/parser_timings.rb +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92a058890ba891a0ccc0d5ef289dd4a5e0067359592ed04f95047a3bf30d0839
4
- data.tar.gz: 833c854ce3e2790ea696f411f5b3c8fd1fd9827e9eca4ffa0d2e3bb21871dd60
3
+ metadata.gz: 73600e70119580caad0f948db3b7140018caefc19479b564d74162b978c95bd1
4
+ data.tar.gz: 227e85a005cc3e043ccd81b13d44aea555dd038f7506e683c48cead1ff2c7e33
5
5
  SHA512:
6
- metadata.gz: e9c9c5e882ecd371ceb24365d46446e863fbcfaac365dbd84c1aed3ffd24fafe2d7b8e7bc7d09babe07fc8e0d8877fb5c112917b6c1915305cb881dc34f8d49c
7
- data.tar.gz: 3206613c98c989672a6d329280c3076efb173e4fea0828b09f57ef4698f546aab8ec8cda04e6ef6ccd9d35101f8b2ae5af0a36b04f5c04fca6afa59543e34706
6
+ metadata.gz: 1af26fb86402e3d42fc9cac2c0657d14b74e0b0ff11424ffce1ae7f747d3583d135474ee77a9a70ed3f47768232f70a8d21aab868151075c93d5e61bfd2bf7ce
7
+ data.tar.gz: e34707b1a27a4da44897f19476dcdf5d1570662f10a897bb28397c70d4b3241eac64eff14bf2ebed7d9f4fd0436a82d4b2ae9652bcd803f00586e3ad66cb915a
data/CHANGES CHANGED
@@ -1,3 +1,50 @@
1
+ 1.4.2 (2020-11-3)
2
+ =====================
3
+ * Do NOT use Ruby 2.7.0 and 2.7.1 with ruby-prof. A bug in those versions of ruby causes ruby-prof to
4
+ not work. Version 2.7.2 works correctly.
5
+ * Fix crash caused be reallocating an internal stack that keeps tracks of frames *after* getting a reference to the
6
+ top frame in the stack (Charlie Savage).
7
+ * Fix bug where the flat printer did not correctly report the correct measurement mode.
8
+
9
+ 1.4.1 (2020-05-14)
10
+ =====================
11
+ * Fix compiling on older versions of gcc that do not default to c99 (Charlie Savage)
12
+
13
+ 1.4.0 (2020-05-12)
14
+ =====================
15
+ * API change - remove merge_fibers support since it resulted in incorrect results or crashes (Charlie Savage)
16
+ * Fix crash when profiling memory usage (Charlie Savage)
17
+ * When tracing execution correctly print out newobj tracepoint events (Charlie Savage)
18
+ * Remove no longer needed code for building extensions (Charlie Savage)
19
+
20
+ 1.3.2 (2020-04-19)
21
+ =====================
22
+ * Fix rack profiler so it is thread safe (Charlie Savage)
23
+ * Fix loading of prebuilt binaries on mingw64 to use Ruby's major and minor version (Charlie Savage)
24
+
25
+ 1.3.1 (2020-03-11)
26
+ =====================
27
+ * Add max_percent and filter_by options to flat printer (Sean McGivern)
28
+ * Include binary in mingw64 build (Charlie Savage)
29
+
30
+ 1.3.0 (2020-02-22)
31
+ =====================
32
+ * Update C code to use newer RTypedData API versus older RData API.
33
+ * Update C code to use rb_cObject versus the older, deprecated, rb_cData.
34
+ * Update memory management - CallInfo's now keep alive their owning Profile instances. Fixes crashes that
35
+ could happen in rare instances.
36
+
37
+ 1.2.0 (2020-01-23)
38
+ =====================
39
+ * Fix call stack printer broken in version 1.0.0 (Charlie Savage)
40
+ * Ruby 2.7.0 support (Charlie Savage)
41
+ * Switch to Windows high precision timer for measuring wall time (Charlie Savage)
42
+ * Much better support for reverse call trees - if you start RubyProf at the bottom
43
+ of a call tree it will correctly calculate times as it ascends the tree (Charlie Savage)
44
+ * Port AggregateCallInfo from Ruby to C to increase performance
45
+ * API change - CallInfo has been renamed CallTree
46
+ * Fix crashes on Ruby 2.4.*
47
+
1
48
  1.1.0 (2019-12-14)
2
49
  =====================
3
50
  Changes
@@ -342,7 +389,7 @@ Fixes
342
389
 
343
390
  0.7.1 (2008-11-28)
344
391
  ========================
345
- * Added new AggregateCallInfo class for printers to
392
+ * Added new AggregateCallTree class for printers to
346
393
  make results easier to read. Take this call sequence
347
394
  for example:
348
395
 
data/Rakefile CHANGED
@@ -6,13 +6,6 @@ require "rake/testtask"
6
6
  require "rdoc/task"
7
7
  require "date"
8
8
  require "rake/clean"
9
- begin
10
- require "bundler/setup"
11
- Bundler::GemHelper.install_tasks
12
- [:build, :install, :release].each {|t| Rake::Task[t].enhance [:rdoc] }
13
- rescue LoadError
14
- $stderr.puts "Install bundler to get support for simplified gem publishing"
15
- end
16
9
 
17
10
  # To release a version of ruby-prof:
18
11
  # * Update lib/ruby-prof/version.rb
@@ -23,10 +16,6 @@ end
23
16
  # * rake package to create the gems
24
17
  # * Tag the release (git tag 0.10.1)
25
18
  # * Push to ruybgems.org (gem push pkg/<gem files>)
26
- # For a ruby only release, just run
27
- # * rake release
28
- # it will push changes to github, tag the release, build the package and upload it to rubygems.org
29
- # and in case you forgot to increment the version number or have uncommitted changes, it will refuse to work
30
19
 
31
20
  GEM_NAME = 'ruby-prof'
32
21
  SO_NAME = 'ruby_prof'
@@ -38,9 +27,9 @@ Rake::ExtensionTask.new do |ext|
38
27
  ext.gem_spec = default_spec
39
28
  ext.name = SO_NAME
40
29
  ext.ext_dir = "ext/#{SO_NAME}"
41
- ext.lib_dir = "lib/#{RUBY_VERSION}"
30
+ ext.lib_dir = "lib/#{Gem::Version.new(RUBY_VERSION).segments[0..1].join('.')}"
42
31
  ext.cross_compile = true
43
- ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
32
+ ext.cross_platform = ['x64-mingw32']
44
33
  end
45
34
 
46
35
  # Rake task to build the default package
@@ -58,7 +47,6 @@ if RUBY_PLATFORM.match(/win32|mingw32/)
58
47
  win_spec = default_spec.clone
59
48
  win_spec.platform = Gem::Platform::CURRENT
60
49
  win_spec.files += Dir.glob('lib/**/*.so')
61
- win_spec.instance_variable_set(:@cache_file, nil) # Hack to work around gem issue
62
50
 
63
51
  # Unset extensions
64
52
  win_spec.extensions = nil
@@ -1,7 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
3
  # First require ruby-prof
4
- require 'rubygems'
5
4
  require 'ruby-prof'
6
5
 
7
6
  # Now setup option parser
@@ -14,64 +13,45 @@ module RubyProf
14
13
  # Profiles a Ruby program.
15
14
  #
16
15
  # == Usage
17
- #
18
- # ruby_prof [options] <script.rb> [--] [script-options]
16
+ # ruby-prof [options] <script.rb> [--] [profiled-script-command-line-options]
19
17
  #
20
18
  # Options:
21
- # -p, --printer=printer Select a printer:
22
- # flat - Prints a flat profile as text (default).
23
- # graph - Prints a graph profile as text.
24
- # graph_html - Prints a graph profile as html.
25
- # call_tree - format for KCacheGrind
26
- # call_stack - prints a HTML visualization of the call tree
27
- # dot - Prints a graph profile as a dot file
28
- # multi - Creates several reports in output directory
29
- #
30
- # -m, --min_percent=min_percent The minimum percent a method must take before
31
- # being included in output reports. This option is not supported for call tree reports.
32
- #
33
- # -f, --file=path Output results to a file instead of standard out.
34
- #
35
- # --mode=measure_mode Select what ruby-prof should measure:
36
- # wall - Wall time (default)
37
- # process - Process time
38
- # allocations - Object allocations
39
- # memory - Allocated memory
40
- #
41
- # -s, --sort=sort_mode Select how ruby-prof results should be sorted:
42
- # total - Total time
43
- # self - Self time
44
- # wait - Wait time
45
- # child - Child time
46
- #
47
- # --replace-progname Replace $0 when loading the .rb files.
48
- #
49
- # --specialized-instruction Turn on specified instruction.
50
- #
51
- # -v Show version, set $VERBOSE to true, profile script if option given
52
- #
53
- # -d Set $DEBUG to true
54
- #
55
- # -R, --require-noprof lib Require a specific library (not profiled)
56
- #
57
- # -E, --eval-noprof code Execute the ruby statements (not profiled)
58
- #
59
- # -x, --exclude regexp Exclude methods by regexp (see method elimination)
60
- #
61
- # -X, --exclude-file file Exclude methods by regexp listed in file (see method elimination)
62
- #
63
- # --exclude-common-cycles Make common iterators like Integer#times appear inlined
64
- #
65
- # --exclude-common-callbacks Make common callbacks invocations like Integer#times appear inlined so you can see call origins in graph
66
- #
67
- # -h, --help Show help message
68
- #
69
- # --version Show version
70
- #
71
- #
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
27
+ # -m, --min_percent=min_percent The minimum percent a method must take before
28
+ # being included in output reports.
29
+ # This option is not supported for call tree.
30
+ # -f, --file=path Output results to a file instead of standard out.
31
+ # --mode=measure_mode Select what ruby-prof should measure:
32
+ # wall - Wall time (default).
33
+ # process - Process time.
34
+ # allocations - Object allocations (requires patched Ruby interpreter).
35
+ # memory - Allocated memory in KB (requires patched Ruby interpreter).
36
+ # -s, --sort=sort_mode Select how ruby-prof results should be sorted:
37
+ # total - Total time
38
+ # self - Self time
39
+ # wait - Wait time
40
+ # 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
49
+ # -v, --version version Show version (1.1.0)
50
+
72
51
  class Cmd
73
52
  # :enddoc:
74
53
  attr_accessor :options
54
+ attr_reader :profile
75
55
 
76
56
  def initialize
77
57
  setup_options
@@ -84,15 +64,52 @@ module RubyProf
84
64
  def setup_options
85
65
  @options = OpenStruct.new
86
66
  options.printer = RubyProf::FlatPrinter
67
+ options.measure_mode = RubyProf::WALL_TIME
87
68
  options.min_percent = 0
88
69
  options.file = nil
89
- options.replace_prog_name = false
90
- options.specialized_instruction = false
91
-
70
+ options.allow_exceptions = false
71
+ options.exclude_common = false
72
+ options.exclude = Array.new
92
73
  options.pre_libs = Array.new
93
74
  options.pre_execs = Array.new
94
75
  end
95
76
 
77
+ # This is copied from ActiveSupport:
78
+ def constantize(camel_cased_word)
79
+ if !camel_cased_word.include?("::")
80
+ Object.const_get(camel_cased_word)
81
+ else
82
+ names = camel_cased_word.split("::")
83
+
84
+ # Trigger a built-in NameError exception including the ill-formed constant in the message.
85
+ Object.const_get(camel_cased_word) if names.empty?
86
+
87
+ # Remove the first blank element in case of '::ClassName' notation.
88
+ names.shift if names.size > 1 && names.first.empty?
89
+
90
+ names.inject(Object) do |constant, name|
91
+ if constant == Object
92
+ constant.const_get(name)
93
+ else
94
+ candidate = constant.const_get(name)
95
+ next candidate if constant.const_defined?(name, false)
96
+ next candidate unless Object.const_defined?(name)
97
+
98
+ # Go down the ancestors to check if it is owned directly. The check
99
+ # stops when we reach Object or the end of ancestors tree.
100
+ constant = constant.ancestors.inject(constant) do |const, ancestor|
101
+ break const if ancestor == Object
102
+ break ancestor if ancestor.const_defined?(name, false)
103
+ const
104
+ end
105
+
106
+ # owner is in Object, so raise
107
+ constant.const_get(name, false)
108
+ end
109
+ end
110
+ end
111
+ end
112
+
96
113
  def option_parser
97
114
  OptionParser.new do |opts|
98
115
  opts.banner = "ruby_prof #{RubyProf::VERSION}\n" +
@@ -182,94 +199,45 @@ module RubyProf
182
199
  end
183
200
  end
184
201
 
185
- opts.on("--replace-progname", "Replace $0 when loading the .rb files.") do
186
- options.replace_prog_name = true
187
- end
188
-
189
- if defined?(RubyVM)
190
- opts.on("--specialized-instruction", "Turn on specified instruction.") do
191
- options.specialized_instruction = true
192
- end
193
- end
194
-
195
202
  opts.on_tail("-h", "--help", "Show help message") do
196
203
  puts opts
197
204
  exit
198
205
  end
199
206
 
200
- opts.on_tail("--version", "Show version #{RubyProf::VERSION}") do
207
+ opts.on_tail("-v version", "--version", "Show version (#{RubyProf::VERSION})") do
201
208
  puts "ruby_prof " + RubyProf::VERSION
202
209
  exit
203
210
  end
204
211
 
205
- opts.on("-v","Show version, set $VERBOSE to true, profile script if option given") do
206
- puts "ruby version: " + [RUBY_PATCHLEVEL, RUBY_PLATFORM, RUBY_VERSION].join(' ')
207
- $VERBOSE = true
208
- end
209
-
210
- opts.on("-d", "Set $DEBUG to true") do
211
- $DEBUG = true
212
+ opts.on('--allow_exceptions', 'Raise exceptions encountered during profiling (true) or suppress them (false)') do
213
+ options.allow_exceptions = true
212
214
  end
213
215
 
214
- opts.on('-R lib', '--require-noprof lib', 'require a specific library (not profiled)') do |lib|
216
+ opts.on('-R lib', '--require-noprof=lib', 'require a specific library (not profiled)') do |lib|
215
217
  options.pre_libs << lib
216
218
  end
217
219
 
218
- opts.on('-E code', '--eval-noprof code', 'execute the ruby statements (not profiled)') do |code|
220
+ opts.on('-E code', '--eval-noprof=code', 'execute the ruby statements (not profiled)') do |code|
219
221
  options.pre_execs << code
220
222
  end
221
223
 
222
- opts.on('-x regexp', '--exclude regexp', 'exclude methods by regexp (see method elimination)') do |meth|
223
- options.eliminate_methods ||= []
224
- options.eliminate_methods << Regexp.new(meth)
225
- end
226
-
227
- opts.on('-X file', '--exclude-file file', 'exclude methods by regexp listed in file (see method elimination)') do|file|
228
- options.eliminate_methods_files ||= []
229
- options.eliminate_methods_files << file
230
- end
231
-
232
- opts.on('--exclude-common-cycles', 'make common iterators like Integer#times appear inlined') do |meth|
233
- options.eliminate_methods ||= []
234
- options.eliminate_methods += %w{
235
- Integer#times
236
- Integer#upto
237
- Integer#downto
238
- Enumerator#each
239
- Enumerator#each_with_index
240
- Enumerator#each_with_object
241
-
242
- Array#each
243
- Array#each_index
244
- Array#reverse_each
245
- Array#map
246
-
247
- Hash#each
248
- Hash#each_pair
249
- Hash#each_key
250
- Hash#each_value
251
-
252
- Range#each
253
- Enumerable#each_cons
254
- Enumerable#each_entry
255
- Enumerable#each_slice
256
- Enumerable#each_with_index
257
- Enumerable#each_with_object
258
- Enumerable#reverse_each
259
- Enumerable#inject
260
- Enumerable#collect
261
- Enumerable#reduce
262
- }
263
- #TODO: may be the whole Enumerable module should be excluded via 'Enumerable#.*', we need feedback on use cases.
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
264
237
  end
265
238
 
266
- opts.on('--exclude-common-callbacks', 'make common callbacks invocations like Integer#times appear inlined so you can see call origins in graph') do|meth|
267
- options.eliminate_methods ||= []
268
- options.eliminate_methods += %w{
269
- Method#call
270
- Proc#call
271
- ActiveSupport::Callbacks::ClassMethods#__run_callback
272
- }
239
+ opts.on('--exclude-common', 'Remove common methods from the profile') do
240
+ options.exclude_common = true
273
241
  end
274
242
  end
275
243
  end
@@ -313,23 +281,15 @@ module RubyProf
313
281
  end
314
282
 
315
283
  def run
316
- # Get the script we will execute
317
284
  script = ARGV.shift
318
- if options.replace_prog_name
319
- $0 = File.expand_path(script)
285
+ @profile = Profile.new(options.to_h)
286
+ options.exclude.each do |klass, method|
287
+ @profile.exclude_method!(klass, method)
320
288
  end
321
289
 
322
- # Set VM compile option
323
- if defined?(RubyVM)
324
- RubyVM::InstructionSequence.compile_option = {
325
- :trace_instruction => true,
326
- :specialized_instruction => options.specialized_instruction
327
- }
290
+ profile.profile do
291
+ load script
328
292
  end
329
-
330
- # Set the measure mode
331
- RubyProf.measure_mode = options.measure_mode if options.measure_mode
332
- RubyProf.start_script(script)
333
293
  end
334
294
  end
335
295
  end
@@ -342,20 +302,8 @@ cmd = RubyProf::Cmd.new
342
302
  # *after* any other one that will be installed.
343
303
 
344
304
  at_exit {
345
- # Stop profiling
346
- result = RubyProf.stop
347
-
348
- # Eliminate unwanted methods from call graph
349
- if cmd.options.eliminate_methods
350
- result.eliminate_methods!(cmd.options.eliminate_methods)
351
- end
352
-
353
- if cmd.options.eliminate_methods_files
354
- cmd.options.eliminate_methods_files.each {|f| result.eliminate_methods!(f)}
355
- end
356
-
357
305
  # Create a printer
358
- printer = cmd.options.printer.new(result)
306
+ printer = cmd.options.printer.new(cmd.profile)
359
307
  printer_options = {:min_percent => cmd.options.min_percent, :sort_method => cmd.options.sort_method}
360
308
 
361
309
  # Get output
@@ -1,36 +1,16 @@
1
1
  require "mkmf"
2
2
 
3
- if RUBY_ENGINE != "ruby"
4
- STDERR.puts("\n\n***** This gem is MRI-specific. It does not support #{RUBY_ENGINE}. *****\n\n")
5
- exit(1)
6
- end
7
-
8
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.4.0')
9
- STDERR.puts("\n\n***** Ruby version #{RUBY_VERSION} is no longer supported. Please upgrade to 2.3 or higher. *****\n\n")
10
- exit(1)
11
- end
12
-
13
- # For the love of bitfields...
14
- $CFLAGS += ' -std=c99'
15
-
16
- # And since we are using C99
17
- CONFIG['warnflags'].gsub!('-Wdeclaration-after-statement', '')
3
+ # This function was added in Ruby 2.5, so once Ruby 2.4 is no longer supported this can be removed
4
+ have_func('rb_tracearg_callee_id', ["ruby.h"])
18
5
 
19
- def add_define(name, value = nil)
20
- if value
21
- $defs.push("-D#{name}=#{value}")
22
- else
23
- $defs.push("-D#{name}")
24
- end
6
+ # We want to intermix declarations and code (ie, don't define all variables at the top of the method)
7
+ unless RUBY_PLATFORM =~ /mswin/
8
+ $CFLAGS += ' -std=c99'
25
9
  end
26
10
 
27
- def windows?
28
- RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
11
+ # And since we are using C99 we want to disable Ruby sending these warnings to gcc
12
+ if CONFIG['warnflags']
13
+ CONFIG['warnflags'].gsub!('-Wdeclaration-after-statement', '')
29
14
  end
30
15
 
31
- add_define("RUBY_PROF_RUBY_VERSION", RUBY_VERSION.split('.')[0..2].inject(0){|v,d| v*100+d.to_i})
32
-
33
- # This function was added in Ruby 2.5, so once Ruby 2.4 is no longer supported this can be removed
34
- have_func('rb_tracearg_callee_id', ["ruby.h"])
35
-
36
16
  create_makefile("ruby_prof")