#!/usr/bin/ruby # Check how much sleep accuracy we have. # # On linux, we can attempt a millisecond sleep and actually get pretty close. # Even jslinux manages to give us about ~11ms. # On windows, it seems like the best we can do is ~15ms. [0.5, 0.2, 0.1, 0.05, 0.02, 0.01, 0.005, 0.002, 0.001, 0.0005, 0.0002, 0.0001].each{|interval| t0 = Time::now 20.times{ sleep interval } t1 = Time::now print "Desired = #{interval}, actual = #{(t1 - t0) / 20.0}\n" }