Storing tic toc values in R
Use the built-in system.time
function:
tm1 <- system.time(
{
#your code here
})
or, alternatively the benchmark
function from rbenchmark
package:
tm2 <- benchmark(
{
#your code here
}, replications=1)
More similar to tic
and toc
and sometimes handier e.g. for status messages in loops:
start <- Sys.time ()
do.something ()
Sys.time () - start
Or you can do as it is described in the 'tictoc' package.
tic("timer")
1+1
toc(log = TRUE, quiet = TRUE)
log.txt <- tic.log(format = TRUE)
tic.clearlog()
your output is then stored in log.txt. You can unlist(log.txt)
and analyse it as a string if you only want the time in seconds.
Cheers,