File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 10
10
# Mas info: https://medium.com/@sachinsoni600517/logging-in-python-a-step-by-step-tutorial-086a617f4eaa
11
11
12
12
import logging
13
+ import time
13
14
14
15
"""
15
16
* EJERCICIO #1:
@@ -48,11 +49,22 @@ class Program():
48
49
def __init__ (self ):
49
50
self .tasks : dict = {}
50
51
logging .debug ('Se inició instancia de la clase.' )
52
+
53
+ def _show_time (func : object ):
54
+ def wraper (* args ):
55
+ start_time : float = time .time ()
56
+ func (* args )
57
+ end_time : float = time .time ()
58
+ logging .debug (f"Tiempo de ejecución: { (end_time - start_time ):.21f} segundos." )
59
+
60
+ return wraper
51
61
62
+ @_show_time
52
63
def add (self , name : str , description : str ):
53
64
self .tasks [name ] = description
54
65
logging .info ('Se agregó una tarea.' )
55
66
67
+ @_show_time
56
68
def delete (self , name : str ):
57
69
if name in self .tasks :
58
70
del self .tasks [name ]
@@ -61,6 +73,7 @@ def delete(self, name: str):
61
73
print ()
62
74
logging .warning (f"No se encontró la tarea '{ name } '." )
63
75
76
+ @_show_time
64
77
def show_list (self ):
65
78
logging .info ('Lista de tareas' )
66
79
for task , des in self .tasks .items ():
@@ -77,3 +90,5 @@ def show_list(self):
77
90
tasks .delete ("a" )
78
91
tasks .show_list ()
79
92
93
+ tasks .delete ("a" )
94
+
You can’t perform that action at this time.
0 commit comments