I am always looking for a way to speed up processing in R before giving up and porting to C++.
To find bottlenecks, I used to put timing variables all over code with print statements. When I discovered R6, I immediately created my own timing class to handle this.
This works great and I love working with R6, but I want something a little more lightweight for when I’m bouncing between multiple R environments. After racking my brain a little, I found that closures provide great solution to such a simple problem. The closure gives us the data persistance we need and doesn’t require outside packages.
You could extend this timer to make fancy output and also put conditional development environment checking. If you really wanted to get sophisticated, you could inject the timer into functions automatically. I may write a post in the future on how to do this. Sounds like fun.