4 ms·
It's not POSIX, but both bash & zsh have real time queries built-in (of course, $(date) is an even older school substitute): t1=$((EPOCHSECONDS + 60))
by cb321 1y ago
It's not POSIX, but both bash & zsh have real time queries built-in (of course, $(date) is an even older school substitute):
t1=$((EPOCHSECONDS + 60))
while [ $EPOCHSECONDS -lt $t1 ]
do # curl ... && break # or whatnot
done
There is also EPOCHREALTIME which gives you a floating point to micro or nanoseconds (for bash/zsh), but only Zsh provides FP arithmetic. There are string-manipulation workarounds, of course. And, yes, with Zsh you might need a
`zmodload zsh/datetime` in there.
These variables seem "under known". EDIT: For example, you can get a quickie wall time measurement from a Zsh shell function like this:
dt () {
t0=$EPOCHREALTIME
"$@"
printf "%.7f wallSec\n" "$((EPOCHREALTIME-t0))" >&2
}
And then you can actually run in your shell
dt echo hi, moon
without even a single fork/clone. (which you can confirm with an off to the side `strace -fv -o/dev/shm/dt.st -p WHATEVER_PID`, although I guess the culture these days is often to have even prompt printing launch a zoo of activity)
- michaelcampbell 1y ago> These variables seem "under known". I speak only for me but TIL these; thanks!