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.
15 16 17 18 19 20 21 22 |
# File 'lib/benchmark/memory/held_results/metric_serializer.rb', line 15 def load(hash) @object = Measurement::Metric.new( hash["type"], hash["allocated"], hash["retained"] ) self end |
#to_h ⇒ Hash
Convert the metric to a Hash.
27 28 29 30 31 32 33 |
# File 'lib/benchmark/memory/held_results/metric_serializer.rb', line 27 def to_h { :allocated => object.allocated, :retained => object.retained, :type => object.type, } end |