I have a function in R which I want to optimize. It is part of the innermost loop so it runs millions of times and I know from profiling that this function takes up about 80% of the total computation time.
I have been using the profvis package to understand where my code is slow and by making incremental improvements a single call of the function now takes less than 10 ms to run.
But at this point, profvis stops working and does not give a useful breakdown of which lines of code are using the most time. For example:
func <- function(x){
x1 <- x ** 2
x2 <- x * 3
x3 <- sum(1:x)
x4 <- x1 + x2 + x3
}
profvis::profvis(func(10))
Error in parse_rprof(prof_output, expr_source) :
No parsing data available. Maybe your function was too fast?
Are their alternative packages or methods that work well to profile functions that take less than 10ms to run?