class Benchmark::Malloc::Allocation

Attributes

class_path[R]
memsize[R]

The allocated object memory size

method_id[R]
object[R]

The allocated object

source_file[R]
source_line[R]

Public Class Methods

new(object) click to toggle source
# File lib/benchmark/malloc/allocation.rb, line 24
def initialize(object)
  @object      = object
  @memsize     = ObjectSpace.memsize_of(object)
  @class_path  = ObjectSpace.allocation_class_path(object)
  @source_file = ObjectSpace.allocation_sourcefile(object)
  @source_line = ObjectSpace.allocation_sourceline(object)
  @method_id   = ObjectSpace.allocation_method_id(object)
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/benchmark/malloc/allocation.rb, line 43
def <=>(other)
  @object <=> other.object &&
    @memsize <=> other.memsize
end
extract(*attributes) click to toggle source
# File lib/benchmark/malloc/allocation.rb, line 33
def extract(*attributes)
  attributes.map do |attr|
    if @object.respond_to?(attr)
      @object.public_send(attr)
    else
      public_send(attr)
    end
  end
end