bug-bash
[Top][All Lists]
Advanced

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

Re: New MILLISECONDS “special” variable?


From: Chet Ramey
Subject: Re: New MILLISECONDS “special” variable?
Date: Thu, 2 Nov 2017 15:35:17 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

On 11/1/17 4:19 PM, Alan Dipert wrote:
> Hello all,
> 
> I understand there is a “special” variable, SECONDS, which returns the
> number of seconds since bash invocation when referenced.
> 
> Unfortunately for tasks like profiling one’s .profile, SECONDS is too
> coarse a unit. Milliseconds are more useful, but getting the time in
> milliseconds is only possibly by calling out to date. (At least, I’m not
> aware of a built-in way to get either Unix epoch or elapsed time in any
> sub-second unit) Shelling out to date isn’t desirable as it adds
> significant overhead and so complicates the task of profiling.

There is a special builtin in the devel branch version (EPOCHREALTIME) that
gives you the epoch time with microsecond resolution. It will be in the
next release.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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