Created
June 12, 2010 17:42
-
-
Save oza/435915 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#/usr/bin/env ruby | |
HZ=250 | |
TICK_PER_USEC = 1000000 / HZ | |
class Timeval | |
attr_accessor :sec, :usec | |
def initialize | |
self.sec = 0 | |
self.usec = 0 | |
end | |
def to_s | |
"sec:" + self.sec.to_s + " usec:" + self.usec.to_s | |
end | |
end | |
def to_tv(skip) | |
tv = Timeval.new | |
val = skip * TICK_PER_USEC | |
tv.sec = val / 1000000 | |
tv.usec = val % 1000000 | |
return tv | |
end | |
tv = Timeval.new | |
puts tv | |
puts to_tv(3) # should be 3*4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment