[前][次][番号順一覧][スレッド一覧]

ruby-changes:56081

From: Nobuyoshi <ko1@a...>
Date: Tue, 11 Jun 2019 23:20:53 +0900 (JST)
Subject: [ruby-changes:56081] Nobuyoshi Nakada: 42f0a8fd6f (trunk): MIN_HZ and MIN_MEASURABLE constants

https://git.ruby-lang.org/ruby.git/commit/?id=42f0a8fd6f

From 42f0a8fd6f7e1f4afcb17aeb34e9f8ddf8d66b9b Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 11 Jun 2019 11:09:02 +0900
Subject: 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.

diff --git a/test/lib/test/unit/assertions.rb b/test/lib/test/unit/assertions.rb
index 9fbf7cb..4431657 100644
--- a/test/lib/test/unit/assertions.rb
+++ b/test/lib/test/unit/assertions.rb
@@ -756,6 +756,11 @@ eom https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit/assertions.rb#L756
         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 https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit/assertions.rb#L770
           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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]