-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.py
More file actions
33 lines (28 loc) · 792 Bytes
/
timer.py
File metadata and controls
33 lines (28 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: UTF-8 -*-
#-------------------------------------------------------------------------------
# Name: Timer
# Purpose:
#
# Author: Albéric
#
# Created: 08/04/2014
# Copyright: (c) Albéric 2014
# Licence: <your licence>
#-------------------------------------------------------------------------------
from time import time
def timed(f):
#decorator for performance
def wrapper(*args, **kwds):
start = time()
result = f(*args, **kwds)
elapsed = time() - start
if elapsed:
print("\t\t\t{}{} took {b:03.2f} ms to finish"\
.format(f.__name__,args, b=elapsed*1000)
)
return result
return wrapper
def main():
pass
if __name__ == '__main__':
main()