[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [minor] "precision" of $SECONDS
From: |
Stephane Chazelas |
Subject: |
Re: [minor] "precision" of $SECONDS |
Date: |
Thu, 25 Feb 2016 13:49:12 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
2016-02-25 13:18:17 +0000, Stephane Chazelas:
[...]
> > function __age { declare ns=$(date +"%N"); declare -i
> > ms=${ns##+(0)}/1000000;
> > 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.7
>
> After 0.4 seconds (at 00:00:01.1), $SECONDS will be 1 (the "bug"
> I'm raising here). "ms" will be 100, so you'll print 1.100
> instead of 0.600. And with my suggested fix, you'd print 0.100.
0.400
Sorry, meant 0.400 above.
--
Stephane