Class: Benchmark::Memory::Measurement
- Inherits:
-
Object
- Object
- Benchmark::Memory::Measurement
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/benchmark/memory/measurement.rb,
lib/benchmark/memory/measurement/metric.rb
Overview
Encapsulate the combined metrics of an action.
Defined Under Namespace
Classes: Metric
Instance Attribute Summary collapse
-
#memory ⇒ Metric
readonly
The memory allocation metric.
-
#metrics ⇒ Array<Metric>
readonly
The metrics for the measurement.
-
#objects ⇒ Metric
readonly
The object allocation metric.
-
#strings ⇒ Metric
readonly
The string allocation metric.
Class Method Summary collapse
-
.from_result(result) ⇒ Object
Create a Measurement from a MemoryProfiler::Results object.
Instance Method Summary collapse
-
#initialize(memory:, objects:, strings:) ⇒ Measurement
constructor
Instantiate a Measurement of memory usage.
Constructor Details
#initialize(memory:, objects:, strings:) ⇒ Measurement
Instantiate a Measurement of memory usage.
30 31 32 33 34 35 |
# File 'lib/benchmark/memory/measurement.rb', line 30 def initialize(memory:, objects:, strings:) @memory = memory @objects = objects @strings = strings @metrics = [@memory, @objects, @strings] end |
Instance Attribute Details
#memory ⇒ Metric (readonly)
Returns The memory allocation metric.
38 39 40 |
# File 'lib/benchmark/memory/measurement.rb', line 38 def memory @memory end |
#metrics ⇒ Array<Metric> (readonly)
Returns The metrics for the measurement.
41 42 43 |
# File 'lib/benchmark/memory/measurement.rb', line 41 def metrics @metrics end |
#objects ⇒ Metric (readonly)
Returns The object allocation metric.
44 45 46 |
# File 'lib/benchmark/memory/measurement.rb', line 44 def objects @objects end |
#strings ⇒ Metric (readonly)
Returns The string allocation metric.
47 48 49 |
# File 'lib/benchmark/memory/measurement.rb', line 47 def strings @strings end |
Class Method Details
.from_result(result) ⇒ Object
Create a Measurement from a MemoryProfiler::Results object.
17 18 19 20 21 22 23 |
# File 'lib/benchmark/memory/measurement.rb', line 17 def self.from_result(result) memory = MetricExtractor.extract_memory(result) objects = MetricExtractor.extract_objects(result) strings = MetricExtractor.extract_strings(result) new(memory: memory, objects: objects, strings: strings) end |