class Benelux::MethodCounter

Attributes

counter[R]

Public Instance Methods

determine_count(args,ret) click to toggle source
# File lib/benelux/packer.rb, line 161
def determine_count(args,ret)
  return 1 if @blk.nil?
  self.instance_exec args, ret, &blk
end
generate_packed_method(callblock=false) click to toggle source
# File lib/benelux/packer.rb, line 146
def generate_packed_method(callblock=false)
  %Q{
  def #{@meth}(*args, &block)
    Benelux.current_track :global unless Benelux.known_thread?
    # Get a reference to this MethodCounter instance
    cmd = Benelux.packed_method #{@klass}, :#{@meth}
    ret = #{@methorig}(*args, &block)
    count = cmd.determine_count(args, ret)
    #Benelux.ld "COUNT(:#{@meth}): \#{count}"
    Benelux.current_track.timeline.add_count :'#{@meth}', count
    ret
  end
  }
end
install_method() click to toggle source
# File lib/benelux/packer.rb, line 142
def install_method
  @klass.module_eval generate_packed_method, __FILE__, 122
end