class Benchmark::Memory::Job::IOOutput::MetricFormatter

Format metrics for use with the IOOutput.

Attributes

metric[R]

@return [Metric] The metric to format.

Public Class Methods

new(metric) click to toggle source

Instantiate a formatter to output a metric into an IO.

@param metric [Measurement::Metric] The metric to format.

# File lib/benchmark/memory/job/io_output/metric_formatter.rb, line 14
def initialize(metric)
  @metric = metric
end

Public Instance Methods

to_s() click to toggle source

Format metric to a string to put on the output.

@return [String]

# File lib/benchmark/memory/job/io_output/metric_formatter.rb, line 24
def to_s
  [
    format("%s %s", scale(metric.allocated), metric.type),
    format("(%s retained)", scale(metric.retained)),
  ].join(" ")
end