Skip to content

Instantly share code, notes, and snippets.

@lucasc896
Created November 19, 2016 13:13
Show Gist options
  • Select an option

  • Save lucasc896/d060b54a014a2d0aebe36c9eec6be8d5 to your computer and use it in GitHub Desktop.

Select an option

Save lucasc896/d060b54a014a2d0aebe36c9eec6be8d5 to your computer and use it in GitHub Desktop.
Simple time decorator
import math
import time
def timeit(func):
def wrap(*args, **kwargs):
start = time.time()
func_returned_value = func(*args, **kwargs)
end = time.time()
print "Function {} returned in {} secs".format(func.__name__,
end-start)
return func_returned_value
return wrap
def calculate():
output = []
for x in xrange(1,10):
output.append(sub_calc(x))
return len(output) * max(output) / sum(output)
@timeit
def sub_calc(y):
return math.log(y) * y ** 0.5
print calculate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment