new xgawk time functions (sleep and gettimeofday)

  • Follow


In case anybody else will find this useful, I have added a
new shared library extension to the xgawk (extensible gawk)
project at http://sourceforge.net/projects/xmlgawk to supply
2 new functions: sleep and gettimeofday.  The sleep
function should pause for the given number of seconds
(the argument is floating-point and should have sub-second
accuracy).  And the gettimeofday function is similar to
the builtin systime() function, except that it should have
sub-second accuracy.  Here is a test script that
demonstrates how it works:

$ cat testtime.awk
@load time

BEGIN {
   delta = 2.347
   printf "Start time = %.6f [systime = %s]\n",t0 = gettimeofday(),
systime()
   printf "Sleep(%s) return code = %s\n",delta,sleep(delta)
   printf "End time = %.6f [systime = %s]\n",t1 = gettimeofday(),
systime()
   printf "Elapsed time = %.6f\n",t1-t0
}

$ xgawk -f testtime.awk
Start time = 1135090599.902198 [systime = 1135090599]
Sleep(2.347) return code = 0
End time = 1135090602.251463 [systime = 1135090602]
Elapsed time = 2.349265

I'm afraid the Windows implementation has probably not been
tested yet, so I would appreciate any feedback on that.

Regards,
Andy

0
Reply aschorr (10) 12/20/2005 2:59:01 PM


0 Replies
171 Views

(page loaded in 0.075 seconds)

Similiar Articles:








7/25/2012 10:01:18 PM


Reply: