Class: Benchmark::Memory::Job::IOOutput::MetricFormatter

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/benchmark/memory/job/io_output/metric_formatter.rb

Overview

Format metrics for use with the IOOutput.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#rjust, scale

Constructor Details

#initialize(metric) ⇒ MetricFormatter

Instantiate a formatter to output a metric into an IO.

Parameters:



14
15
16
# File 'lib/benchmark/memory/job/io_output/metric_formatter.rb', line 14

def initialize(metric)
  @metric = metric
end

Instance Attribute Details

#metricMetric (readonly)

Returns The metric to format.

Returns:

  • (Metric)

    The metric to format.



19
20
21
# File 'lib/benchmark/memory/job/io_output/metric_formatter.rb', line 19

def metric
  @metric
end

Instance Method Details

#to_sString

Format metric to a string to put on the output.

Returns:

  • (String)


24
25
26
27
28
29
# 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