With Chronometry being the accurate measurement of time, I felt that a lot of the existing solutions were best effort or just for show. Measuring command execution time, quite often, is not a requirement. It can offer a baseline or help guide expectations into the amount of time certain tasks might take.

With regards to the solutions already available, take notice to their use of $SECONDS which is exported by default. This is the number of seconds since the shell has been launched. There is no granular measurement such as to the nano, micro or millisecond; when this is most often the measurement of most interest.

Chrono uses a small combination of preexec and precmd hooks to generate a timestamp before the commands runs, after you hit enter, and right before the prompt is re-rendered. We use a small Go-script to get the level of detail we’re looking for, but also to pretty print the elapsed time. When it comes to cross-OS support, this tool solves that problem to, since the most common approach would be to use POSIX date with the %N flag, but this is not supported on macOS.

GitHub - mikemackintosh/chrono
Contribute to mikemackintosh/chrono development by creating an account on GitHub.

Take a look and have fun computing!

Share this post