Blame test/time.awk

Packit 575503
@load "time"
Packit 575503
Packit 575503
# make sure gettimeofday() is consistent with systime().  We must call
Packit 575503
# gettimeofday() before systime() to make sure the subtraction gives 0
Packit 575503
# without risk of rolling over to the next second.
Packit 575503
function timecheck(st,res) {
Packit 575503
   res = gettimeofday()
Packit 575503
   st = systime()
Packit 575503
   printf "gettimeofday - systime = %d\n", res-st
Packit 575503
   return res
Packit 575503
}
Packit 575503
Packit 575503
BEGIN {
Packit 575503
   delta = 1.3
Packit 575503
   t0 = timecheck()
Packit 575503
   printf "sleep(%s) = %s\n",delta,sleep(delta)
Packit 575503
   t1 = timecheck()
Packit 575503
   slept = t1-t0
Packit 575503
   if ((slept < 0.9*delta) || (slept > 1.3*delta))
Packit 575503
      printf "Warning: tried to sleep %.2f secs, but slept for %.2f secs\n",
Packit 575503
	     delta,slept
Packit 575503
}