Every line of 'timeit decorator' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
76 def timeit(func, *args, **kwargs): 77 t0 = datetime.now() 78 result = func(*args, **kwargs) 79 t1 = datetime.now() 80 diff = t1 - t0 81 return {'secs': diff.total_seconds(), 'return_value': result}
112 def timeit(func): 113 def wrapper(*args, **kwargs): 114 start_time = time.time() 115 result = func(*args, **kwargs) 116 end_time = time.time() 117 duration = end_time - start_time 118 ins_log.read_log('info', '%s execute duration :%.3f second' % (str(func), duration)) 119 return result 120 121 return wrapper
21 def timeit(fn): 22 ''' 23 Function decorator to measure execution time 24 @example 25 26 from slm_lab.lib.decorator import timeit 27 @timeit 28 def foo(sec): 29 time.sleep(sec) 30 print('foo') 31 32 foo(1) 33 # => foo 34 # => Timed: foo 1000.9971ms 35 ''' 36 @wraps(fn) 37 def time_fn(*args, **kwargs): 38 start = time.time() 39 output = fn(*args, **kwargs) 40 end = time.time() 41 logger.debug(f'Timed: {fn.__name__} {round((end - start) * 1000, 4)}ms') 42 return output 43 return time_fn
45 def timeit(method): 46 if measure_time is not True: 47 return method 48 49 def timed(*args, **kw): 50 ts = time.time() 51 result = method(*args, **kw) 52 te = time.time() 53 54 print '%r() (%r, %r) %2.2f sec' % (method.__name__, args, kw, te - ts) 55 return result 56 57 return timed
25 def time_decorator(f): 26 return summary.time()(f)
59 def time_it(fn, *args): 60 """ 61 Timing function 62 """ 63 start = time.time() 64 ret = fn(*args) 65 end = time.time() 66 return ((end - start) * 1000, ret)
580 def TimeItWrapper(*args, **kwargs): 581 startTime = time.clock() 582 funcName, _ = GetFuncArgString(func, args, kwargs) 583 res = func(*args, **kwargs) 584 eg.PrintDebugNotice(funcName + " :" + repr(time.clock() - startTime)) 585 return res
40 @wraps(fn) 41 def time_fn(*args, **kwargs): 42 start = time.time() 43 output = fn(*args, **kwargs) 44 end = time.time() 45 logger.debug(f'Timed: {fn.__name__} {round((end - start) * 1000, 4)}ms') 46 return output
114 def __call__(self, func): 115 def wrapped( *args, **kwargs ): 116 start = time.time() 117 print "SphinxReport: phase %s started" % (self.mStage) 118 result = func( *args, **kwargs) 119 print "SphinxReport: phase %s finished in %i seconds" % (self.mStage, time.time() - start) 120 return result 121 return wrapped
62 def wrapper(*args1, ** args2): 63 start = time.time() 64 thread_name = util.thread.get_current_thread_name() 65 ret = fn(*args1, **args2) 66 end = time.time() 67 counter[fn.__name__] = counter[fn.__name__] + (end - start) 68 count_times[fn.__name__] += 1 69 all_time = sum([counter[name] for name in counter]) * 1.0 70 for name in counter: 71 logging.info('\t %s: %f, %f seconds'%(name, counter[name] / all_time, counter[name])) 72 logging.info('\t %s: %d callings, %f seconds per calling'%(name, count_times[name], counter[name] * 1.0 / count_times[name])) 73 s = "Thread [%s]:function [%s] has been called, taking %f seconds"%(thread_name, fn.__name__, (end - start)) 74 # logging.info(s) 75 return ret