On Mon, 24 Jul 2000, Aleksi Niemel wrote: > > I'd like to time some funcs implemented in an extension but they are > > really fast so: > > > > start = Time.now > > my_ext_function(args) > > elapsed_time = Time.now - start > > > > will not do (resolution is microsecs?). > > Some help might be at the > http://dev.rubycentral.com/ref/ref_c_time.html#usec > > And my ruby-cygwin run this (shamelessly ripped from excellent reference): > > ruby -e "t=Time.now; puts ('%10.6f' % t.to_f); puts t.usec;" > > and outputs this: > 964445231.186000 > 186000 > So you're implying that it's only millisecs on your machine then? If so, then I propose an addition to the FAQ and/or Lib reference that answers why / mentions that Time.now.usec is not garantueed to give you the correct number of usecs. > > (Platform-specific syscalls not allowed!) > > This has to be quite platform specific, AFAIK C standards do not impose > requirements for better resolution than second. So my guess, without look to > sources, is that microseconds are not supported on all platforms (and > relying on them is not good idea anyway). > Ok, so we can't hope for anything better than secs/millisecs without going platform-specific then. Point taken on relying on anything less than secs. However I'm not relying on them for any critical func; I'm writing some performance tests. Thanks for your reply, Robert