Skip to content

Commit 1ac2aec

Browse files
committed
measure actual clock res
1 parent 35ade36 commit 1ac2aec

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/rdoc/rdoc_comment_test.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,32 @@ def test_clock_res
204204
assert_equal("clocktime", clockres.inspect)
205205
end
206206

207+
def test_clock_actual_res
208+
clockres = %w[
209+
CLOCK_THREAD_CPUTIME_ID CLOCK_PROCESS_CPUTIME_ID
210+
CLOCK_MONOTONIC
211+
].map do |c|
212+
begin
213+
clk = Process.const_get c
214+
t0 = t = Process.clock_gettime(clk)
215+
cnt = 0
216+
times = [t]
217+
while times.size < 10
218+
t2 = Process.clock_gettime(clk)
219+
if t2 != t
220+
times << t2
221+
t = t2
222+
end
223+
cnt += 1
224+
end
225+
[cnt, times].inspect
226+
rescue => e
227+
e.message
228+
end
229+
end
230+
assert_equal("clock_actualtimes", clockres.inspect)
231+
end
232+
207233
def test_force_encoding
208234
@comment = RDoc::Encoding.change_encoding @comment, Encoding::UTF_8
209235

0 commit comments

Comments
 (0)