[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [minor] "precision" of $SECONDS
From: |
Chet Ramey |
Subject: |
Re: [minor] "precision" of $SECONDS |
Date: |
Thu, 25 Feb 2016 10:48:51 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 |
On 2/25/16 8:18 AM, Stephane Chazelas wrote:
> Similar features would be welcome in bash.
>
> bash has "times" that gives you CPU time with sub-second
> granularity. It's got a "printf %T" a la ksh93, but no %N, its
> $SECOND is only integer (and currently has that issue discussed
> here).
Because bash doesn't have floating point arithmetic. There's no
real reason to have $SECONDS in a format you can't use to perform
calculations.
Bash's %T implementation doesn't have %N because it uses the libc
strftime(3), and as far as I know, no strftime provides it. I assume
that ksh93 implements it internally as part of libast.
Bash doesn't have a `sleep' builtin at all, but there is a loadable
sleep builtin that offers sub-second granularity.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/