MIN_HZ and MIN_MEASURABLE constants
* test/lib/test/unit/assertions.rb (Test::Unit::Assertions): promoted MIN_HZ and MIN_MEASURABLE as constants, which should be constant through the process.
This commit is contained in:
parent
eb016d8353
commit
42f0a8fd6f
@ -756,6 +756,11 @@ eom
|
|||||||
skip
|
skip
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# kernel resolution can limit the minimum time we can measure
|
||||||
|
# [ruby-core:81540]
|
||||||
|
MIN_HZ = MiniTest::Unit::TestCase.windows? ? 67 : 100
|
||||||
|
MIN_MEASURABLE = 1.0 / MIN_HZ
|
||||||
|
|
||||||
def assert_cpu_usage_low(msg = nil, pct: 0.05)
|
def assert_cpu_usage_low(msg = nil, pct: 0.05)
|
||||||
require 'benchmark'
|
require 'benchmark'
|
||||||
|
|
||||||
@ -765,10 +770,7 @@ eom
|
|||||||
warn "test #{msg || 'assert_cpu_usage_low'} too short to be accurate"
|
warn "test #{msg || 'assert_cpu_usage_low'} too short to be accurate"
|
||||||
end
|
end
|
||||||
|
|
||||||
# kernel resolution can limit the minimum time we can measure
|
min_measurable = MIN_MEASURABLE
|
||||||
# [ruby-core:81540]
|
|
||||||
min_hz = windows? ? 67 : 100
|
|
||||||
min_measurable = 1.0 / min_hz
|
|
||||||
min_measurable *= 1.30 # add a little (30%) to account for misc. overheads
|
min_measurable *= 1.30 # add a little (30%) to account for misc. overheads
|
||||||
if max < min_measurable
|
if max < min_measurable
|
||||||
max = min_measurable
|
max = min_measurable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user