Clojure performance testing with macros
When changing some function in a way that has performance implications, I find myself doing this repeatedly:
Adding all that code is tedious and I wanted an easy way to switch between an instrumented version and a normal defn.
This is what I want my macro to do - basically wrapping my function
(+ 1 1) with a start and stop timers.
This is the macro I came up with:
Now I can easily toggle the timer in my function just by adding
PS. How to debug it:
If you clean up the output above of namespaces and autogenerated suffixes, it becomes easier to understand what happens at run time: