Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Jul 2022 09:08:42 +0100
From:      Frank Leonhardt <freebsd-doc@fjl.co.uk>
To:        freebsd-questions@freebsd.org
Subject:   How do get elapsed time in milliseconds in a shell script?
Message-ID:  <4c98bb6d-a128-d10b-a896-6af11c06d41c@fjl.co.uk>

next in thread | raw e-mail | index | archive | help
I thought this would be easy, but it's not!

I can get the time since the epoch to the nearest second (date +%s), but 
nothing more accurate. This was probably good enough in the 1970s but I 
think it's reasonable to want a better resolution even in a shell script.

Yes, I could write something in 'C' in a few lines of 'C' but I want to 
do this using the base system and nothing else.

Does anyone know of any reasonable trick?

Thanks, Frank.

(P.S. I know GNU has a %N extension to strftime())






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4c98bb6d-a128-d10b-a896-6af11c06d41c>