I know there is Rprof (), but it seems rather inaccurate compared to the microbenchmark (). However, if I want to use the microbenchmark () I have to call the function 2 times, one to have the output of it and another to run the time of it (which seems to me quite unfeasible)
I do not know how to call the function only once and have the normal output of the function as well as the precise execution time.
The function is not this, but here is an example of my problem:
teste <- function(x){
Rprof()
x <- x+2
Rprof(NULL)
return(summaryRprof())
}
guarda_x_e_tempo <- teste(2)
or
teste <- function(x){
x <- x+2
return(x)
}
guarda_x <- teste(2)
guarda_tempo <- teste(2)