benchmarks
benchmarks copied to clipboard
Using stderr instead of sockets
can simplify code by much:
how xtime can do it:
r, w = IO.pipe
pid = Process.spawn(*["ruby", "-e", "5.times do; STDERR.puts('msg'); sleep 1; end"], {err: w})
Thread.new do
while true
if IO.select([r])
p r.read_nonblock(1024)
end
end
end
Process.wait(pid)
w.close
r.close