Skip to content

Instantly share code, notes, and snippets.

@c7h c7h/gist:4722329
Last active Dec 12, 2015

Embed
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...
somefoo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.