Re: [minor] "precision" of $SECONDS

2016-02-26 Thread Chet Ramey
On 2/25/16 12:20 PM, Stephane Chazelas wrote: > 2016-02-25 10:48:51 -0500, Chet Ramey: > [...] >> Because bash doesn't have floating point arithmetic. > > Yes, makes sense. mksh having $EPOCHREALTIME floating point even > though it doesn't have floating point arithmetic does sound > weird. > > An

Re: [minor] "precision" of $SECONDS

2016-02-25 Thread Linda Walsh
Stephane Chazelas wrote: 2016-02-25 03:03:41 -0800, Linda Walsh: Stephane Chazelas wrote: $ time bash -c 'while ((SECONDS < 1)); do :; done' bash -c 'while ((SECONDS < 1)); do :; done' 0.39s user 0.00s system 99% cpu 0.387 total Sorry I took "cpu xxx total" to be th

Re: [minor] "precision" of $SECONDS

2016-02-25 Thread Stephane Chazelas
2016-02-25 10:48:51 -0500, Chet Ramey: [...] > Because bash doesn't have floating point arithmetic. Yes, makes sense. mksh having $EPOCHREALTIME floating point even though it doesn't have floating point arithmetic does sound weird. Any plan of adding floating point arithmetic support to bash by t

Re: [minor] "precision" of $SECONDS

2016-02-25 Thread Chet Ramey
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). Becau

Re: [minor] "precision" of $SECONDS

2016-02-25 Thread Stephane Chazelas
2016-02-25 13:18:17 +, Stephane Chazelas: [...] > > function __age { declare ns=$(date +"%N"); declare -i > > ms=${ns##+(0)}/100; > > printf "%4d.%03d\n" $SECONDS $ms > > } > [...] > > I'm not sure how that gives you the time since startup. > Currently, if bash is started at > > 00:00:00

Re: [minor] "precision" of $SECONDS

2016-02-25 Thread Stephane Chazelas
2016-02-25 03:03:41 -0800, Linda Walsh: > Stephane Chazelas wrote: > >$ time bash -c 'while ((SECONDS < 1)); do :; done' > >bash -c 'while ((SECONDS < 1)); do :; done' 0.39s user 0.00s system 99% cpu > >0.387 total > > > >That can take in between 0 and 1 seconds. Or in other words, > >$SECONDS b

Re: [minor] "precision" of $SECONDS

2016-02-25 Thread Linda Walsh
Stephane Chazelas wrote: $ time bash -c 'while ((SECONDS < 1)); do :; done' bash -c 'while ((SECONDS < 1)); do :; done' 0.39s user 0.00s system 99% cpu 0.387 total That can take in between 0 and 1 seconds. Or in other words, $SECONDS becomes 1 in between 0 and 1 second after the shell was st

[minor] "precision" of $SECONDS

2016-02-24 Thread Stephane Chazelas
$ time bash -c 'while ((SECONDS < 1)); do :; done' bash -c 'while ((SECONDS < 1)); do :; done' 0.39s user 0.00s system 99% cpu 0.387 total That can take in between 0 and 1 seconds. Or in other words, $SECONDS becomes 1 in between 0 and 1 second after the shell was started. The reason seems to b