Created
September 30, 2021 17:03
-
-
Save eregon/797eb71fd82c8abe47da0f0d97ec89ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
command = ARGV | |
start = Process.clock_gettime Process::CLOCK_MONOTONIC, :millisecond | |
IO.popen(command, err: [:child, :out]) do |io| | |
while line = io.gets | |
now = Process.clock_gettime Process::CLOCK_MONOTONIC, :millisecond | |
puts "[#{"%5d" % (now - start)}] #{line}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example:
Note the needed
STDOUT.sync = true
(orSTDOUT.flush
), otherwise STDOUT might be block-buffered since it's not a TTY (but a pipe).This is currently not needed on TruffleRuby as there is no write buffering (only read buffering).