On Saturday, January 20, 2018 at 11:03:01 AM UTC-5, Kenny McCormack wrote:
> 1) Why this function? Isn't it the same as the built-in systime() function?
It is not the same. The gettimeofday function has subsecond accuracy.
> 2) Except that it isn't quite the same. Observe:
>
> $ gawk4 -l time 'BEGIN {print gettimeofday(), systime()}'
> 1.51646e+09 1516463840
> $ gawk4 -l time 'BEGIN {printf("%20d%20d\n", gettimeofday(), systime())}'
> 1516463882 1516463882
Here's a better example:
bash-4.2$ gawk -l time 'BEGIN {printf "%.6f %.6f\n", systime(), gettimeofday(); sleep(.1); printf "%.6f %.6f\n", systime(), gettimeofday()}'
1516501463.000000 1516501463.549218
1516501463.000000 1516501463.649364
Regards,
Andy