Sha256: 24c6dc8631e542d2455065f2897a2bafd1e8f642cef88319809afba4da529d64

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require_relative "perf/execution"
require_relative "perf/iteration"
require_relative "perf/version"

module Benchmark
  module Perf
    # Measure iterations a work could take in a second
    #
    # @example
    #   Benchmark::Perf.ips { "foo" + "bar" }
    #
    # @param [Numeric] time
    #   the time to run measurements in seconds
    # @param [Numeric] warmup
    #   the warmup time in seconds
    #
    # @return [Array[Integer, Integer, Integer, Float]]
    #   the average, standard deviation, iterations and time
    #
    # @api public
    def ips(**options, &work)
      Iteration.run(**options, &work)
    end
    module_function :ips

    # Measure execution time(a.k.a cpu time) of a given work
    #
    # @example
    #   Benchmark::Perf.cpu { "foo" + "bar" }
    #
    # @param [Numeric] time
    #   the time to run measurements in seconds
    # @param [Numeric] warmup
    #   the warmup time in seconds
    # @param [Integer] repeat
    #   how many times to repeat measurements
    #
    # @return [Array[Float, Float]]
    #
    # @api public
    def cpu(**options, &work)
      Execution.run(**options, &work)
    end
    module_function :cpu
  end # Perf
end # Benchmark

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
benchmark-perf-0.6.0 lib/benchmark/perf.rb