Class: Benchmark::Memory::Report::Comparison

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/benchmark/memory/report/comparison.rb

Overview

Compare entries against each other.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entries, comparator) ⇒ Comparison

Instantiate a new comparison.

Parameters:

  • entries (Array<Entry>)

    The entries to compare.

  • comparator (Comparator)

    The comparator to use when generating.



14
15
16
17
# File 'lib/benchmark/memory/report/comparison.rb', line 14

def initialize(entries, comparator)
  @entries = entries.sort_by(&comparator)
  @comparator = comparator
end

Instance Attribute Details

#comparatorComparator (readonly)



20
21
22
# File 'lib/benchmark/memory/report/comparison.rb', line 20

def comparator
  @comparator
end

#entriesArray<Entry> (readonly)

Returns The entries to compare.

Returns:

  • (Array<Entry>)

    The entries to compare.



23
24
25
# File 'lib/benchmark/memory/report/comparison.rb', line 23

def entries
  @entries
end

Instance Method Details

#metricSymbol

Returns The metric to compare, one of :memory, :objects, or :strings.

Returns:

  • (Symbol)

    The metric to compare, one of :memory, :objects, or :strings



29
# File 'lib/benchmark/memory/report/comparison.rb', line 29

def_delegators :@comparator, :metric, :value

#possible?Boolean

Check if the comparison is possible

Returns:

  • (Boolean)


34
35
36
# File 'lib/benchmark/memory/report/comparison.rb', line 34

def possible?
  entries.size > 1
end

#valueSymbol

Returns The value to compare, one of :allocated or :retained.

Returns:

  • (Symbol)

    The value to compare, one of :allocated or :retained



29
# File 'lib/benchmark/memory/report/comparison.rb', line 29

def_delegators :@comparator, :metric, :value