bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] measure milliseconds in gawk


From: Andrew J. Schorr
Subject: Re: [bug-gawk] measure milliseconds in gawk
Date: Fri, 14 Dec 2018 15:02:59 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

On Fri, Dec 14, 2018 at 01:42:40PM -0600, Peng Yu wrote:
> I don't think strftime() can give information about milliseconds. Is
> there a way to get milliseconds in gawk? Thanks.

I'm not sure what you mean by "get milliseconds", but are you aware of the
gettimeofday() function in the bundled time extension?

https://www.gnu.org/software/gawk/manual/html_node/Extension-Sample-Time.html

For example:

bash-4.2$ gawk -ltime 'BEGIN {s = gettimeofday(); for (i = 1; i < 1000000; i++) 
x += i; print x; printf "elapsed time = %.6f seconds\n", gettimeofday()-s}'
499999500000
elapsed time = 0.092998 seconds

Regards,
Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]