Skip to content

Commit

Permalink
Remove upper bound check from timing spec
Browse files Browse the repository at this point in the history
Under load, all impls may sleep too long for this spec, so we
remove the upper bound check as in ruby/spec#1212.
  • Loading branch information
headius committed Dec 3, 2024
1 parent f90901d commit 348450a
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions spec/ruby/core/kernel/sleep_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,15 @@ def o.divmod(*); [0, 0.001]; end
t.value.should == 5
end

platform_is_not :darwin do
it "sleeps with nanosecond precision" do
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
100.times do
sleep(0.0001)
end
end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)

actual_duration = end_time - start_time
(actual_duration > 0.01).should == true # 100 * 0.0001 => 0.01
(actual_duration < 0.03).should == true
it "sleeps with nanosecond precision" do
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
100.times do
sleep(0.0001)
end
end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)

actual_duration = end_time - start_time
actual_duration.should > 0.01 # 100 * 0.0001 => 0.01
end

ruby_version_is ""..."3.3" do
Expand Down

0 comments on commit 348450a

Please sign in to comment.