I think this would do:
noop <- function(...) invisible(NULL)
how lazy appreciation comes to the rescue here:
R> system.time(replicate(1e4, noop(runif(1e2))))
user system elapsed
0.01 0.00 0.01
R> system.time(replicate(1e4, noop(runif(1e5))))
user system elapsed
0.01 0.00 0.02
R> system.time(replicate(1e4, noop(runif(1e8))))
user system elapsed
0.01 0.00 0.01
R> system.time(replicate(1e4, noop(runif(1e11))))
user system elapsed
0.01 0.00 0.01
R>
therefore, even when we increase N, no increase in execution time is visible.
source
share