Skip to content

Instantly share code, notes, and snippets.

@oza
Created June 12, 2010 17:42
Show Gist options
  • Save oza/435915 to your computer and use it in GitHub Desktop.
Save oza/435915 to your computer and use it in GitHub Desktop.
#/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