Benchmarking stream reception
===

I am developing a device that send through a serial-usb converter a simple string with about 1s period.
However, as this device is meant to have a real time clock embedded, I need some more time accuracy.
How can I benchmark the time between two consecutive transmissions? Microsecond precision would be great!


Thank you!



Ps.: I've always had problems trying to interface IO objects in Ruby. For example, the following code will only print full lines on the first iteration. All following iterations will print one char each line.

    #Supposing `d` is an IO object connected to my device's stream:
    loop do
    d.each_line{|line| puts line}
    end