summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-11 11:09:02 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-11 23:15:46 +0900
commit42f0a8fd6f7e1f4afcb17aeb34e9f8ddf8d66b9b (patch)
treec14509c2edd03d1d01402b087ecafaab14ad0e4c /test
parenteb016d835373cdce6f08694e527d7a569c208cb5 (diff)
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.
Diffstat (limited to 'test')
-rw-r--r--test/lib/test/unit/assertions.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/test/lib/test/unit/assertions.rb b/test/lib/test/unit/assertions.rb
index 9fbf7cbf95..44316579b4 100644
--- a/test/lib/test/unit/assertions.rb
+++ b/test/lib/test/unit/assertions.rb
@@ -756,6 +756,11 @@ eom
skip
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)
require 'benchmark'
@@ -765,10 +770,7 @@ eom
warn "test #{msg || 'assert_cpu_usage_low'} too short to be accurate"
end
- # kernel resolution can limit the minimum time we can measure
- # [ruby-core:81540]
- min_hz = windows? ? 67 : 100
- min_measurable = 1.0 / min_hz
+ min_measurable = MIN_MEASURABLE
min_measurable *= 1.30 # add a little (30%) to account for misc. overheads
if max < min_measurable
max = min_measurable