The signatures of Benchmark.ips and Benchmark::IPS::Job#initialize are:
module Benchmark
extend self
def ips(calculation = 5, warmup = 2, interactive = STDOUT.tty?, &)
end
module IPS
class Job
def initialize(calculation = 5, warmup = 2, interactive = STDOUT.tty?)
@warmup_time = warmup.seconds
@calculation_time = calculation.seconds
# ...
end
end
end
end
Both calculation and warmup are durations in seconds, yet because of the Number#seconds call it is impossible to actually use a Time::Span here:
# Error: instance variable '@calculation_time' of Benchmark::IPS::Job must be Time::Span, not Int32
Benchmark.ips(5.seconds) do
end
I think those parameters should be restricted to Time::Spans, and Number arguments should be deprecated. (By the way, it seems the only other non-deprecated, public API that accepts a Number as a duration is ::sleep.)
The signatures of
Benchmark.ips
andBenchmark::IPS::Job#initialize
are:Both
calculation
andwarmup
are durations in seconds, yet because of theNumber#seconds
call it is impossible to actually use aTime::Span
here:I think those parameters should be restricted to
Time::Span
s, andNumber
arguments should be deprecated. (By the way, it seems the only other non-deprecated, public API that accepts aNumber
as a duration is::sleep
.)