[R] Multiple expressions in system.time()?

Robert Keefe keef9490 at uidaho.edu
Fri Jul 25 04:10:27 CEST 2003


Hi All,

Is it possible for system.time() to measure the time
it takes for a machine to evaluate more than one R
expression?

For example,

# This I can do:
> system.time(x <- rnorm(100000))
[1] 0.07 0.00 0.13 0.00 0.00

# But this I can't:
> system.time(x <- rnorm(100000); new <- sample(x, 100000, replace=T))
Error: syntax error

# Nor this:
> system.time(x <- rnorm(100000)
+ new <- sample(x, 100000, replace=T)
Error: syntax error

I'm trying to compare two fairly large code chunks,
so executing system.time() individually for each expression
and then summing the results seems suboptimal.

Have I missed something simple?

Thanks in advance for any suggestions-

Rob


version:

platform i386-pc-linux-gnu
arch     i386
os       linux-gnu
system   i386, linux-gnu
status
major    1
minor    7.1
year     2003
month    06
day      16
language R
_____________________________________________________

Rob Keefe                 Lab: (208) 885-5165
M.S. student              Home: (208) 882-9749
University of Idaho




More information about the R-help mailing list