RC Logr 20190315 082448
Friday, 15 Mar, 2019
If you tried using bc to do the quick pi calculation I mentioned yesterday, you can also use an internal value SECONDS to calculate elapsed seconds. The SECONDS only tracks whole numbers, so the time calculation is rather rough, but it works in a pinch.
This works in zsh or bash: SECONDS=0 ; echo "scale=3000; 4*a(1)" | bc -l ; echo $SECONDS
🤓
This also works, using simple math to do date arithmetic (the $(())
triggers the math):
|
|
Or in zsh, this gives output like 1.92s user 0.02s system 99% cpu 1.954 total
:
|
|
In bash, just replace the ()
around the command you are timing with {}
. Calculating pi using this 4*atan(1)
formula is super slow, so anything more than a couple thousand digits will take tiiimeeee.