Skip to content

Instantly share code, notes, and snippets.

@nvdv
Last active October 4, 2016 09:20
Show Gist options
  • Save nvdv/ec9fc3b4f01cc52c000f5855a06d9ba1 to your computer and use it in GitHub Desktop.
Save nvdv/ec9fc3b4f01cc52c000f5855a06d9ba1 to your computer and use it in GitHub Desktop.
How profilers work - profiling decorator
def profile(func):
def wrapper(*args, **kwargs):
start_time = time.time()
result = func(*args, **kwargs)
print("Function %s run time is %f s" % (
func.__name__, time.time() - start_time))
return result
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment