Class: Benchmark::Memory::HeldResults::MetricSerializer
- Inherits:
-
Serializer
- Object
- Serializer
- Benchmark::Memory::HeldResults::MetricSerializer
- Defined in:
- lib/benchmark/memory/held_results/metric_serializer.rb
Overview
Serialize metrics for holding between runs.
Instance Attribute Summary
Attributes inherited from Serializer
Instance Method Summary collapse
-
#load(hash) ⇒ Measurement::Metric
Convert a JSON hash into a Metric.
-
#to_h ⇒ Hash
Convert the metric to a Hash.
Methods inherited from Serializer
Constructor Details
This class inherits a constructor from Benchmark::Memory::HeldResults::Serializer
Instance Method Details
#load(hash) ⇒ Measurement::Metric
Convert a JSON hash into a Metric.
17 18 19 20 21 22 23 24 |
# File 'lib/benchmark/memory/held_results/metric_serializer.rb', line 17 def load(hash) @object = Measurement::Metric.new( hash['type'], hash['allocated'], hash['retained'] ) self end |
#to_h ⇒ Hash
Convert the metric to a Hash.
29 30 31 32 33 34 35 |
# File 'lib/benchmark/memory/held_results/metric_serializer.rb', line 29 def to_h { allocated: object.allocated, retained: object.retained, type: object.type } end |