Closed shenkev closed 5 years ago
I always insert at the top of my code:
try:
dummy = profile
except:
profile = lambda x: x
That way the profiling decorator is a no-ops if I don't run it under kernprof. The only performance penalty, if at all, is at load time.
Currently I'm just commenting out @profile whenever I'm running the code for production and uncommenting @profile when I need to profile. Is there a better way? I don't like explicitly using the LineProfiler class which I believe requires you to pass in the function arguments as well. I want to profile functions as I run them usually.