Class: Benchmark::Memory::Report::Comparison
- Inherits:
-
Object
- Object
- Benchmark::Memory::Report::Comparison
- Extended by:
- Forwardable
- Defined in:
- lib/benchmark/memory/report/comparison.rb
Overview
Compare entries against each other.
Instance Attribute Summary collapse
-
#comparator ⇒ Comparator
readonly
The Comparator to use when generating the Comparison.
-
#entries ⇒ Array<Entry>
readonly
The entries to compare.
Instance Method Summary collapse
-
#initialize(entries, comparator) ⇒ Comparison
constructor
Instantiate a new comparison.
-
#metric ⇒ Symbol
The metric to compare, one of
:memory,:objects, or:strings. -
#possible? ⇒ Boolean
Check if the comparison is possible.
-
#value ⇒ Symbol
The value to compare, one of
:allocatedor:retained.
Constructor Details
#initialize(entries, comparator) ⇒ Comparison
Instantiate a new comparison.
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
#comparator ⇒ Comparator (readonly)
Returns The Benchmark::Memory::Report::Comparator to use when generating the Benchmark::Memory::Report::Comparison.
20 21 22 |
# File 'lib/benchmark/memory/report/comparison.rb', line 20 def comparator @comparator end |
#entries ⇒ Array<Entry> (readonly)
Returns The entries to compare.
23 24 25 |
# File 'lib/benchmark/memory/report/comparison.rb', line 23 def entries @entries end |
Instance Method Details
#metric ⇒ Symbol
Returns 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
34 35 36 |
# File 'lib/benchmark/memory/report/comparison.rb', line 34 def possible? entries.size > 1 end |
#value ⇒ Symbol
Returns The value to compare, one of :allocated or :retained.
29 |
# File 'lib/benchmark/memory/report/comparison.rb', line 29 def_delegators :@comparator, :metric, :value |