File: entry.rb

package info (click to toggle)
ruby-benchmark-memory 0.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 300 kB
  • sloc: ruby: 1,121; makefile: 7; sh: 4
file content (35 lines) | stat: -rw-r--r-- 961 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

require 'forwardable'

module Benchmark
  module Memory
    class Report
      # An entry in a report about a benchmark.
      class Entry
        # Instantiate a new entry.
        #
        # @param label [#to_s] The entry label.
        # @param measurement [Measurement] The measurements for the entry.
        def initialize(label, measurement)
          @label = label
          @measurement = measurement
        end

        # @return [#to_s] The entry label.
        attr_reader :label

        # @return [Measurement] The measurements for the entry.
        attr_reader :measurement

        # Get the total amount of memory allocated in the entry.
        #
        # @param comparison [Comparison] The {Comparison} to compare.
        # @return [Integer]
        def compared_metric(comparison)
          measurement.public_send(comparison.metric).public_send(comparison.value)
        end
      end
    end
  end
end