How to adjust time command to measure a program elapsed time

benchmarkctime

I'm trying to get the time that my program takes to finish (aka elapsed time) so I'm using the common time.

What I get by doing this is 3 measurements: user, system and total. This is fine but I found that the user time that I'm interested in has only two decimal places and I would need more. Is there any way I can get more decimal places out of my time command?

Example: time ./myCProgram
Output: 0.17s user 1.21s system 130% cpu 0.187 total

Wished output wanted: 0.17000s user 1.21s system 130% cpu 0.187 total
(or more decimal places)

Best Answer

If all you want is elapsed time, then with zsh or ksh93:

$ typeset -F SECONDS=0; sleep 1; print "$SECONDS"
1.0012850761

Now, whether that kind of precision makes sense is another matter.

Related Question