When I run the time command in shell time ./myapp
I get an output like the following:
real 0m0.668s
user 0m0.112s
sys 0m0.028s
However,when I run the command \time -f %e ./myapp
I lose precision and I get:
2.01s
If I use the %E
command I also lose precision in the same way. How do I change it to have more precision again, but still only have the seconds being outputted?
I based my research in this Linux / Unix Command: time and on this question
Best Answer
I'm assuming you understand that both these commands are calling a different version of time, right?
bash's built-in version
GNU time aka. /usr/bin/time
The built-in
time
command tobash
can be read up on here:The GNU
time
,/usr/bin/time
, is usually more useful than the built-in.As to your precision problem it's covered here in this github gist, specifically:
Why is bash time more precise then GNU time?
You can see the centiseconds with the following example (see 5th line of output):
More resolution can be had using bash's
time
command like so & you can control the resolution:From the Bash manual on variables: