File tree 2 files changed +37
-0
lines changed
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # Created by imoyao at 2019/5/14 14:16
4
+ import os
5
+ import sys
6
+
7
+ currpath = os .path .join (os .getcwd (), os .path .dirname (__file__ ))
8
+ if currpath not in sys .path :
9
+ sys .path .append (currpath )
10
+
11
+ from . import utils
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # Created by imoyao at 2019/5/14 14:16
4
+ import time
5
+
6
+
7
+ def show_time (func ):
8
+ def wrap_func (* args , ** kwargs ):
9
+ start_time = time .time ()
10
+ ret_result = func (* args , ** kwargs )
11
+ end_time = time .time ()
12
+ print ('The function **{0}** takes {1} time.' .format (func .__name__ , end_time - start_time ))
13
+ return ret_result
14
+
15
+ return wrap_func
16
+
17
+
18
+ @show_time
19
+ def foo (n ):
20
+ for _ in list (range (n )):
21
+ pass
22
+
23
+
24
+ if __name__ == '__main__' :
25
+
26
+ foo (100 )
You can’t perform that action at this time.
0 commit comments