Class: Benchmark::Memory::HeldResults::MeasurementSerializer
- Inherits:
-
Serializer
- Object
- Serializer
- Benchmark::Memory::HeldResults::MeasurementSerializer
- Defined in:
- lib/benchmark/memory/held_results/measurement_serializer.rb
Overview
Serialize measurements for holding between runs.
Instance Attribute Summary
Attributes inherited from Serializer
Instance Method Summary collapse
-
#load(hash) ⇒ Measurement
Convert a JSON hash into a Measurement.
-
#to_h ⇒ Hash
Convert the measurement 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
Convert a JSON hash into a Measurement.
15 16 17 18 19 20 21 22 |
# File 'lib/benchmark/memory/held_results/measurement_serializer.rb', line 15 def load(hash) @object = Measurement.new( :memory => MetricSerializer.load(hash["memory"]), :objects => MetricSerializer.load(hash["objects"]), :strings => MetricSerializer.load(hash["strings"]) ) self end |
#to_h ⇒ Hash
Convert the measurement to a Hash.
27 28 29 30 31 32 33 |
# File 'lib/benchmark/memory/held_results/measurement_serializer.rb', line 27 def to_h { :memory => MetricSerializer.new(object.memory).to_h, :objects => MetricSerializer.new(object.objects).to_h, :strings => MetricSerializer.new(object.strings).to_h, } end |