Skip to content

Instantly share code, notes, and snippets.



Last active Dec 12, 2015
What would you like to do?
primitive built-in debugging w. execution time measurement.
import time
import inspect
start_time = time.time()
debuglevel = 2 #e.g: 0=no 1=error 2=info ...
def printdebug(level, message):
if debuglevel >= level:
curr_time = time.time() - start_time
caller = inspect.stack()[1][3]
print "[%.03fsec] %s: %s" % (curr_time, caller, message)
def somefoo():
#do some foo...
printdebug(2, "foo done")
#do more foo...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment