mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
feat(profiler): add custom tag support (#4710)
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> Signed-off-by: FASTSHIFT <vifextech@foxmail.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
parent
3c67650a5b
commit
605379ab3c
@ -144,13 +144,24 @@ Users can add their own measured functions:
|
||||
|
||||
.. code:: c
|
||||
|
||||
void my_function(void)
|
||||
void my_function_1(void)
|
||||
{
|
||||
LV_PROFILER_BEGIN;
|
||||
do_something();
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
||||
void my_function_2(void)
|
||||
{
|
||||
LV_PROFILER_BEGIN_TAG("do_something_1");
|
||||
do_something_1();
|
||||
LV_PROFILER_END_TAG("do_something_1");
|
||||
|
||||
LV_PROFILER_BEGIN_TAG("do_something_2");
|
||||
do_something_2();
|
||||
LV_PROFILER_END_TAG("do_something_2");
|
||||
}
|
||||
|
||||
Custom profiler implementation
|
||||
******************************
|
||||
|
||||
@ -159,6 +170,9 @@ If you wish to use a profiler method provided by your operating system, you can
|
||||
- :c:macro:`LV_PROFILER_INCLUDE`: Provides a header file for the profiler function.
|
||||
- :c:macro:`LV_PROFILER_BEGIN`: Profiler start point function.
|
||||
- :c:macro:`LV_PROFILER_END`: Profiler end point function.
|
||||
- :c:macro:`LV_PROFILER_BEGIN_TAG`: Profiler start point function with custom tag.
|
||||
- :c:macro:`LV_PROFILER_END_TAG`: Profiler end point function with custom tag.
|
||||
|
||||
|
||||
Taking `NuttX <https://github.com/apache/nuttx>`_ RTOS as an example:
|
||||
|
||||
@ -167,6 +181,8 @@ Taking `NuttX <https://github.com/apache/nuttx>`_ RTOS as an example:
|
||||
#define LV_PROFILER_INCLUDE "nuttx/sched_note.h"
|
||||
#define LV_PROFILER_BEGIN sched_note_begin(NOTE_TAG_ALWAYS)
|
||||
#define LV_PROFILER_END sched_note_end(NOTE_TAG_ALWAYS)
|
||||
#define LV_PROFILER_BEGIN_TAG(str) sched_note_beginex(NOTE_TAG_ALWAYS, str)
|
||||
#define LV_PROFILER_END_TAG(str) sched_note_endex(NOTE_TAG_ALWAYS, str)
|
||||
|
||||
FAQ
|
||||
***
|
||||
@ -179,6 +195,7 @@ Please check the completeness of the logs. If the logs are incomplete, it may be
|
||||
1. Serial port reception errors caused by a high baud rate. You need to reduce the baud rate.
|
||||
2. Data corruption caused by other thread logs inserted during the printing of trace logs. You need to disable the log output of other threads or refer to the configuration above to use a separate log output interface.
|
||||
3. Cross-thread calling of :c:macro:`LV_PROFILER_BEGIN/END`.The built-in LVGL profiler is designed for single-threaded use, so calling it from multiple threads can lead to thread safety issues. If you need to use it in a multi-threaded environment, you can use profiler interfaces provided by your operating system that ensure thread safety.
|
||||
4. Make sure that the string passed in by c:macro:`LV_PROFILER_BEGIN_TAG/END_TAG` is not a local variable on the stack or a string in shared memory, because currently only the string address is recorded and the content is not copied.
|
||||
|
||||
Function execution time displayed as 0s in Perfetto
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -685,6 +685,12 @@
|
||||
|
||||
/*Profiler end point function*/
|
||||
#define LV_PROFILER_END LV_PROFILER_BUILTIN_END
|
||||
|
||||
/*Profiler start point function with custom tag*/
|
||||
#define LV_PROFILER_BEGIN_TAG LV_PROFILER_BUILTIN_BEGIN_TAG
|
||||
|
||||
/*Profiler end point function with custom tag*/
|
||||
#define LV_PROFILER_END_TAG LV_PROFILER_BUILTIN_END_TAG
|
||||
#endif
|
||||
|
||||
/*1: Enable Monkey test*/
|
||||
|
@ -353,12 +353,14 @@ void _lv_display_refr_timer(lv_timer_t * tmr)
|
||||
lv_display_send_event(disp_refr, LV_EVENT_REFR_START, NULL);
|
||||
|
||||
/*Refresh the screen's layout if required*/
|
||||
LV_PROFILER_BEGIN_TAG("layout");
|
||||
lv_obj_update_layout(disp_refr->act_scr);
|
||||
if(disp_refr->prev_scr) lv_obj_update_layout(disp_refr->prev_scr);
|
||||
|
||||
lv_obj_update_layout(disp_refr->bottom_layer);
|
||||
lv_obj_update_layout(disp_refr->top_layer);
|
||||
lv_obj_update_layout(disp_refr->sys_layer);
|
||||
LV_PROFILER_END_TAG("layout");
|
||||
|
||||
/*Do nothing if there is no active screen*/
|
||||
if(disp_refr->act_scr == NULL) {
|
||||
|
@ -2245,6 +2245,24 @@
|
||||
#define LV_PROFILER_END LV_PROFILER_BUILTIN_END
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*Profiler start point function with custom tag*/
|
||||
#ifndef LV_PROFILER_BEGIN_TAG
|
||||
#ifdef CONFIG_LV_PROFILER_BEGIN_TAG
|
||||
#define LV_PROFILER_BEGIN_TAG CONFIG_LV_PROFILER_BEGIN_TAG
|
||||
#else
|
||||
#define LV_PROFILER_BEGIN_TAG LV_PROFILER_BUILTIN_BEGIN_TAG
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*Profiler end point function with custom tag*/
|
||||
#ifndef LV_PROFILER_END_TAG
|
||||
#ifdef CONFIG_LV_PROFILER_END_TAG
|
||||
#define LV_PROFILER_END_TAG CONFIG_LV_PROFILER_END_TAG
|
||||
#else
|
||||
#define LV_PROFILER_END_TAG LV_PROFILER_BUILTIN_END_TAG
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*1: Enable Monkey test*/
|
||||
|
@ -40,6 +40,8 @@ extern "C" {
|
||||
|
||||
#define LV_PROFILER_BEGIN
|
||||
#define LV_PROFILER_END
|
||||
#define LV_PROFILER_BEGIN_TAG(tag) LV_UNUSED(tag)
|
||||
#define LV_PROFILER_END_TAG(tag) LV_UNUSED(tag)
|
||||
|
||||
#endif /*LV_USE_PROFILER*/
|
||||
|
||||
|
@ -26,8 +26,10 @@ extern "C" {
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define LV_PROFILER_BUILTIN_BEGIN lv_profiler_builtin_write(__func__, 'B')
|
||||
#define LV_PROFILER_BUILTIN_END lv_profiler_builtin_write(__func__, 'E')
|
||||
#define LV_PROFILER_BUILTIN_BEGIN_TAG(tag) lv_profiler_builtin_write((tag), 'B')
|
||||
#define LV_PROFILER_BUILTIN_END_TAG(tag) lv_profiler_builtin_write((tag), 'E')
|
||||
#define LV_PROFILER_BUILTIN_BEGIN LV_PROFILER_BUILTIN_BEGIN_TAG(__func__)
|
||||
#define LV_PROFILER_BUILTIN_END LV_PROFILER_BUILTIN_END_TAG(__func__)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
|
Loading…
x
Reference in New Issue
Block a user