Hi All,
I’m using the below function to create line object.
However I found out that the process time increase as the total object number increase.
line = lv_line_create(lv_disp_get_scr_act(g_disp[Chan][disp_count[Chan]]),NULL);
For example,
when I first create the line, it takes about 0.024ms to process lv_create_line()
However, when the total object number increase to 180, it takes about 0.087ms to create a line object.
May I know the reason?
Or Could someone guide me how to improve this?
Futhermore, I found out that
lv_obj_set_style_local_line_xxx has the same situation. (process time increase as total object number increase.)
The code block(s) should be formatted like:
void DrawLine(UINT32 Chan, UINT32 X1, UINT32 Y1, UINT32 X2, UINT32 Y2, UINT32 LineWidth, UINT32 Color, UINT32 *LineTotal)
{
lv_obj_t * line;
lv_color_t line_color;
lv_point_t _point[2] = {{(lv_coord_t)X1,(lv_coord_t)Y1},{(lv_coord_t)X2,(lv_coord_t)Y2}};
line_points[Chan][line_count[Chan]] = _point[0];
line_points[Chan][line_count[Chan]+1U] = _point[1];
line_color.full = Color;
/* Measure time */
line = lv_line_create(lv_disp_get_scr_act(g_disp[Chan][disp_count[Chan]]),NULL);
/* Measure time */
lv_obj_set_pos(line,0,0);
lv_obj_add_style(line,LV_LINE_PART_MAIN,&style_line);
lv_line_set_points(line,&line_points[Chan][line_count[Chan]],2U);
lv_obj_set_style_local_line_color(line,LV_OBJ_PART_MAIN,LV_STATE_DEFAULT,line_color);
lv_obj_set_style_local_line_width(line,LV_OBJ_PART_MAIN,LV_STATE_DEFAULT,(lv_coord_t)LineWidth);
lv_obj_set_style_local_line_opa(line,LV_OBJ_PART_MAIN,LV_STATE_DEFAULT,Color>>24);
}
I’ve check further into the source code, and found out that it is void * lv_mem_alloc(size_t size) that takes most of the time.
Since I do not use custome malloc, therefore, the code flow should run below
#if LV_MEM_CUSTOM == 0
/*Use the built-in allocators*/
lv_mem_ent_t * e = NULL;
/* Search for a appropriate entry*/
do {
/* Get the next entry*/
e = ent_get_next(e);
/*If there is next entry then try to allocate there*/
if(e != NULL) {
alloc = ent_alloc(e, size);
}
/* End if there is not next entry OR the alloc. is successful*/
} while(e != NULL && alloc == NULL);
#else
I think it is because object is getting more and more, therefore, it takes more than to find next entry.
May I know is there a good solution to improve this?
Many Thanks for your help.