Class: Benchmark::Malloc::Allocation
- Inherits:
-
Object
- Object
- Benchmark::Malloc::Allocation
- Includes:
- Comparable
- Defined in:
- lib/benchmark/malloc/allocation.rb
Instance Attribute Summary collapse
-
#class_path ⇒ Object
readonly
Returns the value of attribute class_path.
-
#memsize ⇒ Object
readonly
The allocated object memory size.
-
#method_id ⇒ Object
readonly
Returns the value of attribute method_id.
-
#object ⇒ Object
readonly
The allocated object.
-
#source_file ⇒ Object
readonly
Returns the value of attribute source_file.
-
#source_line ⇒ Object
readonly
Returns the value of attribute source_line.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #extract(*attributes) ⇒ Object
-
#initialize(object) ⇒ Allocation
constructor
A new instance of Allocation.
Constructor Details
#initialize(object) ⇒ Allocation
Returns a new instance of Allocation.
24 25 26 27 28 29 30 31 |
# 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 |
Instance Attribute Details
#class_path ⇒ Object (readonly)
Returns the value of attribute class_path.
16 17 18 |
# File 'lib/benchmark/malloc/allocation.rb', line 16 def class_path @class_path end |
#memsize ⇒ Object (readonly)
The allocated object memory size
14 15 16 |
# File 'lib/benchmark/malloc/allocation.rb', line 14 def memsize @memsize end |
#method_id ⇒ Object (readonly)
Returns the value of attribute method_id.
22 23 24 |
# File 'lib/benchmark/malloc/allocation.rb', line 22 def method_id @method_id end |
#object ⇒ Object (readonly)
The allocated object
11 12 13 |
# File 'lib/benchmark/malloc/allocation.rb', line 11 def object @object end |
#source_file ⇒ Object (readonly)
Returns the value of attribute source_file.
18 19 20 |
# File 'lib/benchmark/malloc/allocation.rb', line 18 def source_file @source_file end |
#source_line ⇒ Object (readonly)
Returns the value of attribute source_line.
20 21 22 |
# File 'lib/benchmark/malloc/allocation.rb', line 20 def source_line @source_line end |
Instance Method Details
#<=>(other) ⇒ Object
43 44 45 46 |
# File 'lib/benchmark/malloc/allocation.rb', line 43 def <=>(other) @object <=> other.object && @memsize <=> other.memsize end |
#extract(*attributes) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# 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 |