This is a simple class I created to debug code in python
You just import the Debugger class and instantiate it on a "with" block.
If you want to disable the debugger simply put debug(False)
at the beginning of your code.
TIP: You can use pdb first to see where your script is taking most of the execution time and then put that code inside of a Debugger block.
You can call it like this on the terminal:
time ./app.py
This will be the output:
--BEGIN--
------------------------------------------------------------
Thu Jun 22 15:31:25 2023 - <downloading data from the servers>
------------------------------------------------------------
------------------------------------------------------------
Thu Jun 22 15:31:28 2023 - </downloading data from the servers>
Elapsed time: 3.00
------------------------------------------------------------
--END--
--BEGIN--
------------------------------------------------------------
Thu Jun 22 15:31:28 2023 - <making costly math with data>
------------------------------------------------------------
------------------------------------------------------------
Thu Jun 22 15:31:30 2023 - </making costly math with data>
Elapsed time: 2.00
------------------------------------------------------------
--END--
--BEGIN--
------------------------------------------------------------
Thu Jun 22 15:31:30 2023 - <uploading results to the database>
------------------------------------------------------------
------------------------------------------------------------
Thu Jun 22 15:31:35 2023 - </uploading results to the database>
Elapsed time: 5.01
------------------------------------------------------------
--END--
./app.py 0.02s user 0.03s system 0% cpu 10.105 total