lib/ruby-prof/compatibility.rb in ruby-prof-0.15.9 vs lib/ruby-prof/compatibility.rb in ruby-prof-0.16.0

- old
+ new

@@ -38,12 +38,12 @@ # call-seq: # measure_mode -> measure_mode # # Returns what ruby-prof is measuring. Valid values include: # - # *RubyProf::PROCESS_TIME - Measure process time. This is default. It is implemented using the clock functions in the C Runtime library. - # *RubyProf::WALL_TIME - Measure wall time using gettimeofday on Linx and GetLocalTime on Windows + # *RubyProf::WALL_TIME - Measure wall time using gettimeofday on Linx and GetLocalTime on Windows. This is default. + # *RubyProf::PROCESS_TIME - Measure process time. It is implemented using the clock functions in the C Runtime library. # *RubyProf::CPU_TIME - Measure time using the CPU clock counter. This mode is only supported on Pentium or PowerPC platforms. # *RubyProf::ALLOCATIONS - Measure object allocations. This requires a patched Ruby interpreter. # *RubyProf::MEMORY - Measure memory size. This requires a patched Ruby interpreter. # *RubyProf::GC_RUNS - Measure number of garbage collections. This requires a patched Ruby interpreter. # *RubyProf::GC_TIME - Measure time spent doing garbage collection. This requires a patched Ruby interpreter.*/ @@ -55,12 +55,12 @@ # call-seq: # measure_mode=value -> void # # Specifies what ruby-prof should measure. Valid values include: # - # *RubyProf::PROCESS_TIME - Measure process time. This is default. It is implemented using the clock functions in the C Runtime library. - # *RubyProf::WALL_TIME - Measure wall time using gettimeofday on Linx and GetLocalTime on Windows + # *RubyProf::WALL_TIME - Measure wall time using gettimeofday on Linx and GetLocalTime on Windows. This is default. + # *RubyProf::PROCESS_TIME - Measure process time. It is implemented using the clock functions in the C Runtime library. # *RubyProf::CPU_TIME - Measure time using the CPU clock counter. This mode is only supported on Pentium or PowerPC platforms. # *RubyProf::ALLOCATIONS - Measure object allocations. This requires a patched Ruby interpreter. # *RubyProf::MEMORY - Measure memory size. This requires a patched Ruby interpreter. # *RubyProf::GC_RUNS - Measure number of garbage collections. This requires a patched Ruby interpreter. # *RubyProf::GC_TIME - Measure time spent doing garbage collection. This requires a patched Ruby interpreter.*/ @@ -104,11 +104,11 @@ load script end def self.start ensure_not_running! - @profile = Profile.new(self.measure_mode, self.exclude_threads) + @profile = Profile.new(measure_mode: measure_mode, exclude_threads: exclude_threads) enable_gc_stats_if_needed @profile.start end def self.pause @@ -138,15 +138,16 @@ @profile = nil result end # Profile a block - def self.profile(&block) + def self.profile(options = {}, &block) ensure_not_running! gc_stat_was_enabled = enable_gc_stats_if_needed - res = Profile.profile(self.measure_mode, self.exclude_threads, &block) + options = { measure_mode: measure_mode, exclude_threads: exclude_threads }.merge!(options) + result = Profile.profile(options, &block) disable_gc_stats_if_needed(gc_stat_was_enabled) - res + result end private def self.ensure_running!