module RubyProf
These methods are deprecated and are available for backwards compatability.
Constants
- VERSION
Public Class Methods
Returns the threads that ruby-prof should exclude from profiling
# File lib/ruby-prof/compatibility.rb 32 def self.exclude_threads 33 @exclude_threads ||= Array.new 34 end
Specifies which threads ruby-prof should exclude from profiling
# File lib/ruby-prof/compatibility.rb 37 def self.exclude_threads=(value) 38 @exclude_threads = value 39 end
Returns what ruby-prof is measuring. Valid values include:
-
RubyProf::WALL_TIME
-
RubyProf::PROCESS_TIME
-
RubyProf::ALLOCATIONS
-
RubyProf::MEMORY
# File lib/ruby-prof/compatibility.rb 14 def self.measure_mode 15 @measure_mode ||= RubyProf::WALL_TIME 16 end
Specifies what ruby-prof should measure. Valid values include:
-
RubyProf::WALL_TIME - Wall time measures the real-world time elapsed between any two moments. If there are other processes concurrently running on the system that use significant CPU or disk time during a profiling run then the reported results will be larger than expected. On Windows, wall time is measured using GetTickCount(), on MacOS by mach_absolute_time, on Linux by clock_gettime and otherwise by gettimeofday.
-
RubyProf::PROCESS_TIME - Process time measures the time used by a process between any two moments. It is unaffected by other processes concurrently running on the system. Remember with process time that calls to methods like sleep will not be included in profiling results. On Windows, process time is measured using GetProcessTimes and on other platforms by clock_gettime.
-
RubyProf::ALLOCATIONS - Object allocations measures show how many objects each method in a program allocates. Measurements are done via Ruby’s GC.stat api.
-
RubyProf::MEMORY - Memory measures how much memory each method in a program uses. Measurements are done via Ruby’s TracePoint api.
# File lib/ruby-prof/compatibility.rb 27 def self.measure_mode=(value) 28 @measure_mode = value 29 end
Pauses profiling
# File lib/ruby-prof/compatibility.rb 49 def self.pause 50 ensure_running! 51 @profile.pause 52 end
Profiles a block
# File lib/ruby-prof/compatibility.rb 78 def self.profile(options = {}, &block) 79 ensure_not_running! 80 options = {:measure_mode => measure_mode, :exclude_threads => exclude_threads }.merge!(options) 81 Profile.profile(options, &block) 82 end
Resume profiling
# File lib/ruby-prof/compatibility.rb 64 def self.resume 65 ensure_running! 66 @profile.resume 67 end
Is a profile running?
# File lib/ruby-prof/compatibility.rb 55 def self.running? 56 if defined?(@profile) and @profile 57 @profile.running? 58 else 59 false 60 end 61 end
Starts profiling
# File lib/ruby-prof/compatibility.rb 42 def self.start 43 ensure_not_running! 44 @profile = Profile.new(:measure_mode => measure_mode, :exclude_threads => exclude_threads) 45 @profile.start 46 end
Stops profiling
# File lib/ruby-prof/compatibility.rb 70 def self.stop 71 ensure_running! 72 result = @profile.stop 73 @profile = nil 74 result 75 end