It is possible to record the time that was used to run some code using system.time
. Here is a little example:
system.time(
mean(rnorm(10^6))
)
But I am not only interested in the time but also in the number of arithmetic operations (that is +,-,*,/) that were used for the code.
In the above-mentioned case it would be easy to count the number of summations and the division in order to get the mean, but the code I would like to apply this to is far more complex.
Therefore, my question is: is there a function in R that counts the number of arithmetic operations?