Class: Benchmark::Memory::Measurement::Metric

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/benchmark/memory/measurement/metric.rb

Overview

Describe the ratio of allocated vs. retained memory in a measurement.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, allocated, retained) ⇒ Metric

Instantiate a Metric of allocated vs. retained memory.

Parameters:

  • type (Symbol)

    The type of memory allocated in the metric.

  • allocated (Integer)

    The amount allocated in the metric.

  • retained (Integer)

    The amount retained in the metric.



15
16
17
18
19
# File 'lib/benchmark/memory/measurement/metric.rb', line 15

def initialize(type, allocated, retained)
  @type = type
  @allocated = allocated
  @retained = retained
end

Instance Attribute Details

#allocatedInteger (readonly)

Returns The amount allocated in the metric.

Returns:

  • (Integer)

    The amount allocated in the metric.



22
23
24
# File 'lib/benchmark/memory/measurement/metric.rb', line 22

def allocated
  @allocated
end

#retainedInteger (readonly)

Returns The amount retained in the metric.

Returns:

  • (Integer)

    The amount retained in the metric.



25
26
27
# File 'lib/benchmark/memory/measurement/metric.rb', line 25

def retained
  @retained
end

#typeSymbol (readonly)

Returns The type of memory allocated in the metric.

Returns:

  • (Symbol)

    The type of memory allocated in the metric.



28
29
30
# File 'lib/benchmark/memory/measurement/metric.rb', line 28

def type
  @type
end

Instance Method Details

#<=>(other) ⇒ Integer

Sort by the total allocated.

Parameters:

  • other (Metric)

    The other metric.

Returns:

  • (Integer)


35
36
37
# File 'lib/benchmark/memory/measurement/metric.rb', line 35

def <=>(other)
  allocated <=> other.allocated
end