3

I am running a command on my OS which outputs thousands of lines, sometimes delaying in the middle for a couple of seconds, before restarting. Is there a way to find the time elapsed, in ms, between these lines of outputs?

A time stamp would work but I would prefer to output the time differences to a file.

1 Answers1

3

If you have homebrew, install moreutils to get the ts command, which can add incremental timestamps to input:

$ (echo foo; sleep 0.1; echo bar; sleep 0.2; echo foo) | ts -i '%.s'
0.000013 foo
0.077336 bar
0.210087 foo
muru
  • 72,889