|
333 | 333 |
|
334 | 334 | (assert (pos? (length (gensym))) "gensym not empty, regression #753")
|
335 | 335 |
|
| 336 | +(assert-no-error (os/clock :realtime) "realtime clock") |
| 337 | +(assert-no-error (os/clock :cputime) "cputime clock") |
| 338 | +(assert-no-error (os/clock :monotonic) "monotonic clock") |
336 | 339 |
|
337 |
| -# os/clock. These tests might prove fragile under CI because they |
338 |
| -# rely on measured time. We'll see. |
339 |
| - |
340 |
| -(defmacro measure-time [clocks & body] |
341 |
| - (def [t1 t2] [(gensym) (gensym)]) |
342 |
| - ~(do |
343 |
| - (def ,t1 (map |(os/clock $) ,clocks)) |
344 |
| - ,;body |
345 |
| - (def ,t2 (map |(os/clock $) ,clocks)) |
346 |
| - (zipcoll ,clocks (map |(- ;$) (map tuple ,t2 ,t1)))) |
347 |
| -) |
348 |
| - |
349 |
| -# Spin for 0.1 seconds |
350 |
| -(def dt (measure-time [:realtime :monotonic :cputime] |
351 |
| - (def t1 (os/clock :monotonic)) |
352 |
| - (while (< (- (os/clock :monotonic) t1) 0.1) true))) |
353 |
| -(assert (> (dt :monotonic) 0.10)) |
354 |
| -(assert (> (dt :cputime) 0.05)) |
355 |
| - |
356 |
| -# Sleep for 0.1 seconds |
357 |
| -(def dt (measure-time [:realtime :monotonic :cputime] (os/sleep 0.1))) |
358 |
| -(assert (> (dt :monotonic) 0.10)) |
359 |
| -(assert (< (dt :cputime) 0.05)) |
| 340 | +(def before (os/clock :monotonic)) |
| 341 | +(def after (os/clock :monotonic)) |
| 342 | +(assert (>= after before) "monotonic clock is monotonic") |
360 | 343 |
|
361 | 344 | (end-suite)
|
0 commit comments