Class: RSpec::Memory::Allocation

Inherits:
Struct
  • Object
show all
Defined in:
lib/rspec/memory/trace.rb

Constant Summary collapse

SLOT_SIZE =
ObjectSpace.memsize_of(Object.new)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#countObject

Returns the value of attribute count

Returns:

  • (Object)

    the current value of count



11
12
13
# File 'lib/rspec/memory/trace.rb', line 11

def count
  @count
end

#sizeObject

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



11
12
13
# File 'lib/rspec/memory/trace.rb', line 11

def size
  @size
end

Class Method Details

.default_hashObject



21
22
23
# File 'lib/rspec/memory/trace.rb', line 21

def self.default_hash
	Hash.new{|h,k| h[k] = Allocation.new(0, 0)}
end

Instance Method Details

#<<(object) ⇒ Object



14
15
16
17
18
19
# File 'lib/rspec/memory/trace.rb', line 14

def << object
	self.count += 1
	
	# We don't want to force specs to take the slot size into account.
	self.size += ObjectSpace.memsize_of(object) - SLOT_SIZE
end