class Wildsight::Profiler::Profiler

Public Class Methods

new(context) click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 5
def initialize(context)
  @context = context
  @data = {}
  @profile = nil
end

Public Instance Methods

data() click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 30
def data
  @data
end
duration(name, time = nil, options = {}, &block) click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 11
def duration(name, time = nil, options = {}, &block)
  p = @profile = Profile.new(name, @profile)
  @profile.options = options

  if block_given?
    @profile.profile!(&block)
  else
    @profile.set(time[0], time[1])
  end

  @profile = @profile.close

  durations(name)[:intervals] << p.export
  durations(name)[:duration] += p.duration

  raise p.exception if p.exception
  return p.result
end
durations(name) click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 34
def durations(name)
  @data[name] ||= { intervals: [], duration: 0.0 }
end