aboutsummaryrefslogtreecommitdiffstats
path: root/test/time.awk
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2012-08-17 12:38:04 +0300
committerArnold D. Robbins <arnold@skeeve.com>2012-08-17 12:38:04 +0300
commite6b05afd9971b457c0b46907a91185b66be8ff4e (patch)
treee7d3b6fce47a2ac7b32cdf923ceb6e50db9fe441 /test/time.awk
parent3b23e177cd166e96c700379491b4a99bddf9aa4d (diff)
parent76cc4d241f328876b18e48639d631823c3d304d6 (diff)
downloadegawk-e6b05afd9971b457c0b46907a91185b66be8ff4e.tar.gz
egawk-e6b05afd9971b457c0b46907a91185b66be8ff4e.tar.bz2
egawk-e6b05afd9971b457c0b46907a91185b66be8ff4e.zip
Merge branch 'extgawk'
Diffstat (limited to 'test/time.awk')
-rw-r--r--test/time.awk22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/time.awk b/test/time.awk
new file mode 100644
index 00000000..517377e2
--- /dev/null
+++ b/test/time.awk
@@ -0,0 +1,22 @@
+@load "time"
+
+# make sure gettimeofday() is consistent with systime(). We must call
+# gettimeofday() before systime() to make sure the subtraction gives 0
+# without risk of rolling over to the next second.
+function timecheck(st,res) {
+ res = gettimeofday()
+ st = systime()
+ printf "gettimeofday - systime = %d\n", res-st
+ return res
+}
+
+BEGIN {
+ delta = 1.3
+ t0 = timecheck()
+ printf "sleep(%s) = %s\n",delta,sleep(delta)
+ t1 = timecheck()
+ slept = t1-t0
+ if ((slept < 0.9*delta) || (slept > 1.3*delta))
+ printf "Warning: tried to sleep %.2f secs, but slept for %.2f secs\n",
+ delta,slept
+}