summaryrefslogtreecommitdiff
path: root/test/lib
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/test/unit/assertions.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/lib/test/unit/assertions.rb b/test/lib/test/unit/assertions.rb
index 976a6fd04a..92f754064a 100644
--- a/test/lib/test/unit/assertions.rb
+++ b/test/lib/test/unit/assertions.rb
@@ -715,6 +715,13 @@ eom
skip
end
+ def assert_cpu_usage_low(msg = nil, pct: 0.005)
+ require 'benchmark'
+ tms = Benchmark.measure(msg || '') { yield }
+ max = pct * tms.real
+ assert_operator tms.total, :<=, max, msg
+ end
+
def assert_is_minus_zero(f)
assert(1.0/f == -Float::INFINITY, "#{f} is not -0.0")
end