Is there a standardized way in R of measuring execution time of function?
Obviously I can take system.time before and after execution and then take the difference of those, but I would like to know if there is some standardized way or function (would like to not invent the wheel).
I seem to remember that I have once used something like below:
somesysfunction("myfunction(with,arguments)")
> Start time : 2001-01-01 00:00:00 # output of somesysfunction
> "Result" "of" "myfunction" # output of myfunction
> End time : 2001-01-01 00:00:10 # output of somesysfunction
> Total Execution time : 10 seconds # output of somesysfunction
proc.timeon mind causesystem.timeis one you need.Rprofis nice. It provides a profile of all the processes in a code chunk/function.require(microbenchmark)is now (since a couple years ago) the community standard way to time things.times <- microbenchmark( lm(y~x), glm(y~x), times=1e3); example(microbenchmark). This does a statistical comparison oflmvsglmover 1000 tries, rather thansystem.timetesting only once.res <- microbenchmark(your code1,your code2)and thenprint(res)to see a table orggplot2::autoplot(res)to see a boxplot! ref