class Benchmark::Memory::HeldResults::MetricSerializer

Serialize metrics for holding between runs.

Public Instance Methods

load(hash) click to toggle source

Convert a JSON hash into a Metric.

@param hash [Hash] A JSON document hash.

@return [Measurement::Metric]

# 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() click to toggle source

Convert the metric to a Hash.

@return [Hash] The metric as a Hash.

# File lib/benchmark/memory/held_results/metric_serializer.rb, line 27
def to_h
  {
    :allocated => object.allocated,
    :retained  => object.retained,
    :type      => object.type,
  }
end