This commit is contained in:
adii1823
2021-10-28 17:40:37 +05:30
parent 0c8daddd31
commit 3cebc2fe91
11 changed files with 296 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
# custom_timestamp.py
from time import sleep
def debug(*msg, timestamp=[None]):
print(*msg)
from time import time # local import
if timestamp[0] is None:
timestamp[0] = time() #1
else:
now = time()
print(
' Time elapsed: {:.3f}s'.format(now - timestamp[0])
)
timestamp[0] = now #2
debug('Entering nasty piece of code...')
sleep(.3)
debug('First step done.')
sleep(.5)
debug('Second step done.')
"""
$ python custom_timestamp.py
Entering nasty piece of code...
First step done.
Time elapsed: 0.300s
Second step done.
Time elapsed: 0.500s
"""