Simple profiler for IDF Monitor
Posted: Wed Sep 06, 2017 4:37 pm
I needed to make a simple profiler for my project,
so I modified idf_monitor.py for this.
It's very simple, I read the time in micros at the beginning of each line,
calculate and show the difference between the time of the line and the time of the previous line
and display this in yellow or red.
There is an parameter in line 276:
self.MIN_MICROS_RED = 50 #if the time is equal or greater, show profiler in red
This was very useful for me, because my project was generating a lot of debugging, and with this profiler it became easier to identify the bottlenecks
Follow the file idf_monitor.py, just go to $ IDF_PATH, rename the original file and copy the new idf_monitor.py
I am not a python programmer,
I tried to put a control-key for turn on / off the profiler, but I did not succeed
If the profiler is useful to other people,
my suggestion is that this can be evaluated, corrected and go to the framework.
I hope it's useful
Regards
Joao Lopes
-------------
An example of the profiler in action (please note the value after P( ):
I (4114) P (0) wifi :: Connected !!! IP: 192.168.0.117
I (4119) P (5) wifi :: Initialized -> Running callback
I (4125) P (6) uart :: Submitting data: (22) -> T0123456789001234567890
I (4131) P (6) socket_server :: WiFi connected
I (4135) P (4) socket_server :: Creating TCP Server ...
I (4141) P (6) socket_server :: Creating TCP port server = NNNN
I (4148) P (7) socket_server :: TCP server created successfully!
I (4153) P (5) socket_server :: Socket Server initialized
I (4159) P (6) socket_server :: Server socket - waiting for connections ...
I (4646) P (487) main :: test
I (5646) P (1000) main :: test
I (6646) P (1000) main :: test
I (7646) P (1000) main :: test
I (8646) P (1000) main :: test
so I modified idf_monitor.py for this.
It's very simple, I read the time in micros at the beginning of each line,
calculate and show the difference between the time of the line and the time of the previous line
and display this in yellow or red.
There is an parameter in line 276:
self.MIN_MICROS_RED = 50 #if the time is equal or greater, show profiler in red
This was very useful for me, because my project was generating a lot of debugging, and with this profiler it became easier to identify the bottlenecks
Follow the file idf_monitor.py, just go to $ IDF_PATH, rename the original file and copy the new idf_monitor.py
I am not a python programmer,
I tried to put a control-key for turn on / off the profiler, but I did not succeed
If the profiler is useful to other people,
my suggestion is that this can be evaluated, corrected and go to the framework.
I hope it's useful
Regards
Joao Lopes
-------------
An example of the profiler in action (please note the value after P( ):
I (4114) P (0) wifi :: Connected !!! IP: 192.168.0.117
I (4119) P (5) wifi :: Initialized -> Running callback
I (4125) P (6) uart :: Submitting data: (22) -> T0123456789001234567890
I (4131) P (6) socket_server :: WiFi connected
I (4135) P (4) socket_server :: Creating TCP Server ...
I (4141) P (6) socket_server :: Creating TCP port server = NNNN
I (4148) P (7) socket_server :: TCP server created successfully!
I (4153) P (5) socket_server :: Socket Server initialized
I (4159) P (6) socket_server :: Server socket - waiting for connections ...
I (4646) P (487) main :: test
I (5646) P (1000) main :: test
I (6646) P (1000) main :: test
I (7646) P (1000) main :: test
I (8646) P (1000) main :: test