Module: Benchmark::Perf

Defined in:
lib/benchmark/perf.rb,
lib/benchmark/perf/clock.rb,
lib/benchmark/perf/stats.rb,
lib/benchmark/perf/version.rb,
lib/benchmark/perf/execution.rb,
lib/benchmark/perf/iteration.rb,
lib/benchmark/perf/cpu_result.rb,
lib/benchmark/perf/ips_result.rb

Defined Under Namespace

Modules: Clock, Execution, Iteration, Stats Classes: CPUResult, IPSResult

Constant Summary collapse

VERSION =
"0.6.0"

Class Method Summary collapse

Class Method Details

.cpu(**options, &work) ⇒ Array[Float, Float]

Measure execution time(a.k.a cpu time) of a given work

Examples:

Benchmark::Perf.cpu { "foo" + "bar" }

Parameters:

  • time (Numeric)

    the time to run measurements in seconds

  • warmup (Numeric)

    the warmup time in seconds

  • repeat (Integer)

    how many times to repeat measurements

Returns:

  • (Array[Float, Float])


43
44
45
# File 'lib/benchmark/perf.rb', line 43

def cpu(**options, &work)
  Execution.run(**options, &work)
end

.ips(**options, &work) ⇒ Array[Integer, Integer, Integer, Float]

Measure iterations a work could take in a second

Examples:

Benchmark::Perf.ips { "foo" + "bar" }

Parameters:

  • time (Numeric)

    the time to run measurements in seconds

  • warmup (Numeric)

    the warmup time in seconds

Returns:

  • (Array[Integer, Integer, Integer, Float])

    the average, standard deviation, iterations and time



23
24
25
# File 'lib/benchmark/perf.rb', line 23

def ips(**options, &work)
  Iteration.run(**options, &work)
end