def measure_runtime(func):
 def time_taken(obj, num):
  'Prints the time taken by func to run a given number of samples.\n\n        Args:\n            obj: object. The class instance func belongs to.\n            num: int. The number of samples to run with.\n\n        Returns:\n            Result of func.\n        '
  start = time.time()
  result = func(obj, num)
  end = time.time()
  print ('%s spent %f seconds for %d instances' % (func.__name__, (end - start), num))
  return result
 return time_taken

def measure_runtime ( func ) : def time_taken ( obj , num ) : start = time . time ( ) result = func ( obj , num ) end = time . time ( ) print ( '%s spent %f seconds for %d instances' % ( func . __name__ , ( end - start ) , num ) ) return result return time_taken
a decorator that measures the amount of time func takes to run .