This is a note to self (so I don’t forgot about it) – it is not rocket science 😉

If you need to check how long it takes to run part of your bash script you can use the use PS4 trick, as explained partially here, but it is a bit messy and I don’t like to do the math by hand 😛

In order to test the performance bottleneck of one of my shell scripts I draft a small set of functions.
One to start the clock ticking, another to check how long it passed since the last mark and another to reset the clock.

You can download/copy into a file of your choice and then source it inside your script. The output is the nanoseconds passed between operations. If you make (any) use of it please let me know. I don’t think it will blow up your computer, but you’re at your own risk 😉