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.

Would a patch adding a MILLISECONDS variable be considered? I would be
happy to work on one, if so.

I can imagine many reasons not to add a new variable, including the fact
that it could change the behavior of existing scripts. It may also be the
case that there’s already a method to get sub-second times without shelling
out, and so I’d be grateful for pointers to any existing solutions.

Thank you in advance for your thoughts, I look forward to hearing them.

Alan

Reply via email to