Skip to content

Commit 14aea11

Browse files
authored
Merge pull request #194 from vimm0/auto
Add execution timer function
2 parents 8db472e + 3f1e440 commit 14aea11

File tree

1 file changed

+19
-0
lines changed
  • Automation/src/execution_timer

1 file changed

+19
-0
lines changed

Automation/src/execution_timer/et.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
Decorator for execution time evaluation
3+
Usage
4+
=====
5+
# @exec_time
6+
# def function_name():
7+
"""
8+
def exec_time(func):
9+
"""Returns the execution time of a function"""
10+
import timeit
11+
12+
def wrapper(*args, **kwargs):
13+
start_time = timeit.default_timer()
14+
res = func(*args, **kwargs)
15+
elapsed = timeit.default_timer() - start_time
16+
print('Elapsed time: %f' % elapsed)
17+
return res
18+
19+
return wrapper

0 commit comments

Comments
 (0)