FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Python/code/Python Modules/timymodule.py at master · shreydan/Python · GitHub
shreydan
/
Python
Public
Notifications
You must be signed in to change notification settings
Fork
11
Star
18
Code
Issues
2
Pull requests
0
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Python
/
code
/
Python Modules
/
timymodule.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (35 loc) · 1.21 KB
Breadcrumbs
Python
/
code
/
Python Modules
/
timymodule.py
Copy path
File metadata and controls
44 lines (35 loc) · 1.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
34
35
36
37
38
39
40
41
42
43
44
"""
Written by: Shreyas Daniel - github.com/shreydan
Description: an overview of 'timy' module - pip install timy
A great alternative to Pythons 'timeit' module and easier to use.
"""
import
timy
# begin by importing timy
@
timy
.
timer
(
ident
=
'listcomp'
,
loops
=
1
)
# timy decorator
def
listcomprehension
():
# the function whose execution time is calculated.
li
=
[
x
for
x
in
range
(
0
,
100000
,
2
)]
listcomprehension
()
"""
this is how the above works:
timy property is created.
any function underneath the timy decorator is the function whose execution time
need to be calculated.
after the function is called. The execution time is printed.
in the timy decorator:
ident: an identity for each timy property, handy when using a lot of them
loops: no. of times this function has to be executed
"""
# this can also be accomplished by 'with' statement:
# tracking points in between code can be added
# to track specific instances in the program
def
listcreator
():
with
timy
.
Timer
()
as
timer
:
li
=
[]
for
i
in
range
(
0
,
100000
,
2
):
li
.
append
(
i
)
if
i
==
50000
:
timer
.
track
(
'reached 50000'
)
listcreator
()
"""
there are many more aspects to 'timy' module.
check it out here: https://github.com/ramonsaraiva/timy
"""
Back
|
FazBrowse Home
|
New Git URL