[R] sleep timer resolution on OSX

From: ivo welch <ivowel_at_gmail.com>
Date: Fri, 11 Jun 2010 22:41:23 -0400

I am doing some timing experiments. To test looping performance, I used the Sys.sleep function. I noticed something in the docs that is just a little misleading:

" The resolution of the time

     interval is system-dependent, but will normally be down to 0.02
     secs or better. (On modern Unix-alikes it will be better than

on OSX, which is (almost) a modern Unix-alike, and a very common platform,

> system.time( for (i in 1:100) Sys.sleep(0.001) )

   user system elapsed
  0.005 0.004 1.020
> system.time( for (i in 1:100) Sys.sleep(0.01) )

   user system elapsed
  0.005 0.004 1.019

so, the resolution seems to be about 0.01 seconds. under linux, similar time experiments show that the resolution is under 0.0001 seconds.

just wanted to put this into the r-archives for google searches. (if I could make changes to the docs, I would note it there instead.)

hope this helps someone else...


Ivo Welch (ivo.welch_at_brown.edu, ivo.welch_at_gmail.com)

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 12 Jun 2010 - 07:37:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 12 Jun 2010 - 09:50:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive