[R] timing a function

Gabor Grothendieck ggrothendieck at myway.com
Sun Mar 21 15:23:32 CET 2004



Just one tip in regard to the information already provided
by others.

If you time two functions to compare them and it just so happens
that a garbage collection occurs within one but not the other
then your timing will be distorted.  To control for this issue
a gc() command just before each system.time command:

gc(); system.time(x <- rnorm(1000000))

That will cause a garbage collection to occur before the
code is run so that it starts out from a known state.

Another thing you could do is to try running from a fresh
R session.


Date:   Sat, 20 Mar 2004 10:11:03 -0800 (PST) 
From:   Fred J. <phddas at yahoo.com>
To:   r help <r-help at stat.math.ethz.ch> 
Subject:   [R] timing a function 

 
Hello
is there a way to time how long it takes to run a code
in R. somthing like tic toc in matlab as such?
help.search("timing") put out nothing.
and while I got you, debugging the code, is there a
step through and the rest of the debugging tools
working with ESS.

thanks




More information about the R-help mailing list