mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
fix(benchmark): improve the benchmark (#5558)
This commit is contained in:
parent
973a6f062a
commit
f880cc8c15
@ -117,12 +117,15 @@ static void multiple_rgb_images_cb(void)
|
||||
lv_obj_set_style_pad_row(lv_screen_active(), 20, 0);
|
||||
|
||||
LV_IMG_DECLARE(img_benchmark_cogwheel_rgb);
|
||||
uint32_t hor_cnt = (lv_display_get_horizontal_resolution(NULL) - 16) / 116;
|
||||
uint32_t ver_cnt = (lv_display_get_vertical_resolution(NULL) - 116) / 116;
|
||||
int32_t hor_cnt = ((int32_t)lv_display_get_horizontal_resolution(NULL) - 16) / 116;
|
||||
int32_t ver_cnt = ((int32_t)lv_display_get_vertical_resolution(NULL) - 116) / 116;
|
||||
|
||||
uint32_t y;
|
||||
if(hor_cnt < 1) hor_cnt = 1;
|
||||
if(ver_cnt < 1) ver_cnt = 1;
|
||||
|
||||
int32_t y;
|
||||
for(y = 0; y < ver_cnt; y++) {
|
||||
uint32_t x;
|
||||
int32_t x;
|
||||
for(x = 0; x < hor_cnt; x++) {
|
||||
lv_obj_t * obj = lv_img_create(lv_screen_active());
|
||||
lv_image_set_src(obj, &img_benchmark_cogwheel_rgb);
|
||||
@ -140,12 +143,15 @@ static void multiple_argb_images_cb(void)
|
||||
lv_obj_set_style_pad_row(lv_screen_active(), 20, 0);
|
||||
|
||||
LV_IMG_DECLARE(img_benchmark_cogwheel_argb);
|
||||
uint32_t hor_cnt = (lv_display_get_horizontal_resolution(NULL) - 16) / 116;
|
||||
uint32_t ver_cnt = (lv_display_get_vertical_resolution(NULL) - 116) / 116;
|
||||
int32_t hor_cnt = ((int32_t)lv_display_get_horizontal_resolution(NULL) - 16) / 116;
|
||||
int32_t ver_cnt = ((int32_t)lv_display_get_vertical_resolution(NULL) - 116) / 116;
|
||||
|
||||
uint32_t y;
|
||||
if(hor_cnt < 1) hor_cnt = 1;
|
||||
if(ver_cnt < 1) ver_cnt = 1;
|
||||
|
||||
int32_t y;
|
||||
for(y = 0; y < ver_cnt; y++) {
|
||||
uint32_t x;
|
||||
int32_t x;
|
||||
for(x = 0; x < hor_cnt; x++) {
|
||||
lv_obj_t * obj = lv_img_create(lv_screen_active());
|
||||
lv_image_set_src(obj, &img_benchmark_cogwheel_argb);
|
||||
@ -163,12 +169,15 @@ static void rotated_argb_image_cb(void)
|
||||
lv_obj_set_style_pad_row(lv_screen_active(), 20, 0);
|
||||
|
||||
LV_IMG_DECLARE(img_benchmark_cogwheel_argb);
|
||||
uint32_t hor_cnt = (lv_display_get_horizontal_resolution(NULL) - 16) / 116;
|
||||
uint32_t ver_cnt = (lv_display_get_vertical_resolution(NULL) - 116) / 116;
|
||||
int32_t hor_cnt = ((int32_t)lv_display_get_horizontal_resolution(NULL) - 16) / 116;
|
||||
int32_t ver_cnt = ((int32_t)lv_display_get_vertical_resolution(NULL) - 116) / 116;
|
||||
|
||||
uint32_t y;
|
||||
if(hor_cnt < 1) hor_cnt = 1;
|
||||
if(ver_cnt < 1) ver_cnt = 1;
|
||||
|
||||
int32_t y;
|
||||
for(y = 0; y < ver_cnt; y++) {
|
||||
uint32_t x;
|
||||
int32_t x;
|
||||
for(x = 0; x < hor_cnt; x++) {
|
||||
lv_obj_t * obj = lv_img_create(lv_screen_active());
|
||||
lv_image_set_src(obj, &img_benchmark_cogwheel_argb);
|
||||
@ -190,10 +199,12 @@ static void multiple_labels_cb(void)
|
||||
lv_text_get_size(&s, "Hello LVGL!", lv_obj_get_style_text_font(lv_screen_active(), 0), 0, 0, LV_COORD_MAX,
|
||||
LV_TEXT_FLAG_NONE);
|
||||
|
||||
uint32_t cnt = (lv_display_get_horizontal_resolution(NULL) - 16) / (s.x + 30);
|
||||
int32_t cnt = (lv_display_get_horizontal_resolution(NULL) - 16) / (s.x + 30);
|
||||
cnt = cnt * ((lv_display_get_vertical_resolution(NULL) - 200) / (s.y + 50));
|
||||
|
||||
uint32_t i;
|
||||
if(cnt < 1) cnt = 1;
|
||||
|
||||
int32_t i;
|
||||
for(i = 0; i < cnt; i++) {
|
||||
lv_obj_t * obj = lv_label_create(lv_screen_active());
|
||||
lv_label_set_text(obj, "Hello LVGL!");
|
||||
@ -227,12 +238,15 @@ static void multiple_arcs_cb(void)
|
||||
lv_obj_set_flex_align(lv_screen_active(), LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
||||
|
||||
LV_IMG_DECLARE(img_benchmark_cogwheel_argb);
|
||||
uint32_t hor_cnt = (lv_display_get_horizontal_resolution(NULL) - 16) / lv_dpx(160);
|
||||
uint32_t ver_cnt = (lv_display_get_vertical_resolution(NULL) - 16) / lv_dpx(160);
|
||||
int32_t hor_cnt = (lv_display_get_horizontal_resolution(NULL) - 16) / lv_dpx(160);
|
||||
int32_t ver_cnt = (lv_display_get_vertical_resolution(NULL) - 16) / lv_dpx(160);
|
||||
|
||||
uint32_t y;
|
||||
if(hor_cnt < 1) hor_cnt = 1;
|
||||
if(ver_cnt < 1) ver_cnt = 1;
|
||||
|
||||
int32_t y;
|
||||
for(y = 0; y < ver_cnt; y++) {
|
||||
uint32_t x;
|
||||
int32_t x;
|
||||
for(x = 0; x < hor_cnt; x++) {
|
||||
|
||||
lv_obj_t * obj = lv_arc_create(lv_screen_active());
|
||||
@ -259,12 +273,15 @@ static void containers_cb(void)
|
||||
lv_obj_set_flex_flow(lv_screen_active(), LV_FLEX_FLOW_ROW_WRAP);
|
||||
lv_obj_set_flex_align(lv_screen_active(), LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
||||
|
||||
uint32_t hor_cnt = (lv_display_get_horizontal_resolution(NULL) - 16) / 300;
|
||||
uint32_t ver_cnt = (lv_display_get_vertical_resolution(NULL) - 16) / 150;
|
||||
int32_t hor_cnt = ((int32_t)lv_display_get_horizontal_resolution(NULL) - 16) / 300;
|
||||
int32_t ver_cnt = ((int32_t)lv_display_get_vertical_resolution(NULL) - 16) / 150;
|
||||
|
||||
uint32_t y;
|
||||
if(hor_cnt < 1) hor_cnt = 1;
|
||||
if(ver_cnt < 1) ver_cnt = 1;
|
||||
|
||||
int32_t y;
|
||||
for(y = 0; y < ver_cnt; y++) {
|
||||
uint32_t x;
|
||||
int32_t x;
|
||||
for(x = 0; x < hor_cnt; x++) {
|
||||
lv_obj_t * card = card_create();
|
||||
if(x == 0) lv_obj_add_flag(card, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK);
|
||||
@ -278,12 +295,15 @@ static void containers_with_overlay_cb(void)
|
||||
lv_obj_set_flex_flow(lv_screen_active(), LV_FLEX_FLOW_ROW_WRAP);
|
||||
lv_obj_set_flex_align(lv_screen_active(), LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
||||
|
||||
uint32_t hor_cnt = (lv_display_get_horizontal_resolution(NULL) - 16) / 300;
|
||||
uint32_t ver_cnt = (lv_display_get_vertical_resolution(NULL) - 16) / 150;
|
||||
int32_t hor_cnt = ((int32_t)lv_display_get_horizontal_resolution(NULL) - 16) / 300;
|
||||
int32_t ver_cnt = ((int32_t)lv_display_get_vertical_resolution(NULL) - 16) / 150;
|
||||
|
||||
uint32_t y;
|
||||
if(hor_cnt < 1) hor_cnt = 1;
|
||||
if(ver_cnt < 1) ver_cnt = 1;
|
||||
|
||||
int32_t y;
|
||||
for(y = 0; y < ver_cnt; y++) {
|
||||
uint32_t x;
|
||||
int32_t x;
|
||||
for(x = 0; x < hor_cnt; x++) {
|
||||
lv_obj_t * card = card_create();
|
||||
if(x == 0) lv_obj_add_flag(card, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK);
|
||||
@ -300,12 +320,15 @@ static void containers_with_opa_cb(void)
|
||||
lv_obj_set_flex_flow(lv_screen_active(), LV_FLEX_FLOW_ROW_WRAP);
|
||||
lv_obj_set_flex_align(lv_screen_active(), LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
||||
|
||||
uint32_t hor_cnt = (lv_display_get_horizontal_resolution(NULL) - 16) / 300;
|
||||
uint32_t ver_cnt = (lv_display_get_vertical_resolution(NULL) - 16) / 150;
|
||||
int32_t hor_cnt = ((int32_t)lv_display_get_horizontal_resolution(NULL) - 16) / 300;
|
||||
int32_t ver_cnt = ((int32_t)lv_display_get_vertical_resolution(NULL) - 16) / 150;
|
||||
|
||||
uint32_t y;
|
||||
if(hor_cnt < 1) hor_cnt = 1;
|
||||
if(ver_cnt < 1) ver_cnt = 1;
|
||||
|
||||
int32_t y;
|
||||
for(y = 0; y < ver_cnt; y++) {
|
||||
uint32_t x;
|
||||
int32_t x;
|
||||
for(x = 0; x < hor_cnt; x++) {
|
||||
lv_obj_t * card = card_create();
|
||||
if(x == 0) lv_obj_add_flag(card, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK);
|
||||
@ -320,12 +343,15 @@ static void containers_with_opa_layer_cb(void)
|
||||
lv_obj_set_flex_flow(lv_screen_active(), LV_FLEX_FLOW_ROW_WRAP);
|
||||
lv_obj_set_flex_align(lv_screen_active(), LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
||||
|
||||
uint32_t hor_cnt = (lv_display_get_horizontal_resolution(NULL) - 16) / 300;
|
||||
uint32_t ver_cnt = (lv_display_get_vertical_resolution(NULL) - 16) / 150;
|
||||
int32_t hor_cnt = ((int32_t)lv_display_get_horizontal_resolution(NULL) - 16) / 300;
|
||||
int32_t ver_cnt = ((int32_t)lv_display_get_vertical_resolution(NULL) - 16) / 150;
|
||||
|
||||
uint32_t y;
|
||||
if(hor_cnt < 1) hor_cnt = 1;
|
||||
if(ver_cnt < 1) ver_cnt = 1;
|
||||
|
||||
int32_t y;
|
||||
for(y = 0; y < ver_cnt; y++) {
|
||||
uint32_t x;
|
||||
int32_t x;
|
||||
for(x = 0; x < hor_cnt; x++) {
|
||||
lv_obj_t * card = card_create();
|
||||
lv_obj_set_style_opa_layered(card, LV_OPA_50, 0);
|
||||
|
@ -1055,6 +1055,8 @@ static void wait_for_flushing(lv_display_t * disp)
|
||||
LV_PROFILER_BEGIN;
|
||||
LV_LOG_TRACE("begin");
|
||||
|
||||
lv_display_send_event(disp, LV_EVENT_FLUSH_WAIT_START, NULL);
|
||||
|
||||
if(disp->flush_wait_cb) {
|
||||
disp->flush_wait_cb(disp);
|
||||
}
|
||||
@ -1063,6 +1065,8 @@ static void wait_for_flushing(lv_display_t * disp)
|
||||
}
|
||||
disp->flushing_last = 0;
|
||||
|
||||
lv_display_send_event(disp, LV_EVENT_FLUSH_WAIT_FINISH, NULL);
|
||||
|
||||
LV_LOG_TRACE("end");
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
@ -107,6 +107,8 @@ typedef enum {
|
||||
LV_EVENT_RENDER_READY,
|
||||
LV_EVENT_FLUSH_START,
|
||||
LV_EVENT_FLUSH_FINISH,
|
||||
LV_EVENT_FLUSH_WAIT_START,
|
||||
LV_EVENT_FLUSH_WAIT_FINISH,
|
||||
|
||||
LV_EVENT_VSYNC,
|
||||
|
||||
|
@ -126,18 +126,31 @@ static void perf_monitor_disp_event_cb(lv_event_t * e)
|
||||
info->measured.refr_cnt++;
|
||||
break;
|
||||
case LV_EVENT_RENDER_START:
|
||||
info->measured.render_in_progress = 1;
|
||||
info->measured.render_start = lv_tick_get();
|
||||
break;
|
||||
case LV_EVENT_RENDER_READY:
|
||||
info->measured.render_in_progress = 0;
|
||||
info->measured.render_elaps_sum += lv_tick_elaps(info->measured.render_start);
|
||||
info->measured.render_cnt++;
|
||||
break;
|
||||
case LV_EVENT_FLUSH_START:
|
||||
info->measured.flush_start = lv_tick_get();
|
||||
case LV_EVENT_FLUSH_WAIT_START:
|
||||
if(info->measured.render_in_progress) {
|
||||
info->measured.flush_in_render_start = lv_tick_get();
|
||||
}
|
||||
else {
|
||||
info->measured.flush_not_in_render_start = lv_tick_get();
|
||||
}
|
||||
break;
|
||||
case LV_EVENT_FLUSH_FINISH:
|
||||
info->measured.flush_elaps_sum += lv_tick_elaps(info->measured.flush_start);
|
||||
info->measured.flush_cnt++;
|
||||
case LV_EVENT_FLUSH_WAIT_FINISH:
|
||||
if(info->measured.render_in_progress) {
|
||||
info->measured.flush_in_render_elaps_sum += lv_tick_elaps(info->measured.flush_in_render_start);
|
||||
}
|
||||
else {
|
||||
info->measured.flush_not_in_render_elaps_sum += lv_tick_elaps(info->measured.flush_not_in_render_start);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -171,11 +184,13 @@ static void perf_update_timer_cb(lv_timer_t * t)
|
||||
info->calculated.cpu = 100 - LV_SYSMON_GET_IDLE();
|
||||
info->calculated.refr_avg_time = info->measured.refr_cnt ? (info->measured.refr_elaps_sum / info->measured.refr_cnt) :
|
||||
0;
|
||||
info->calculated.flush_avg_time = info->measured.flush_cnt ? (info->measured.flush_elaps_sum / info->measured.flush_cnt)
|
||||
: 0;
|
||||
|
||||
info->calculated.flush_avg_time = info->measured.render_cnt ?
|
||||
((info->measured.flush_in_render_elaps_sum + info->measured.flush_not_in_render_elaps_sum)
|
||||
/ info->measured.render_cnt) : 0;
|
||||
/*Flush time was measured in rendering time so subtract it*/
|
||||
info->calculated.render_avg_time = info->measured.render_cnt ? ((info->measured.render_elaps_sum -
|
||||
info->measured.flush_elaps_sum) /
|
||||
info->measured.flush_in_render_elaps_sum) /
|
||||
info->measured.render_cnt) : 0;
|
||||
|
||||
info->calculated.cpu_avg_total = ((info->calculated.cpu_avg_total * (info->calculated.run_cnt - 1)) +
|
||||
|
@ -52,9 +52,11 @@ typedef struct {
|
||||
uint32_t render_start;
|
||||
uint32_t render_elaps_sum; /*Contains the flush time too*/
|
||||
uint32_t render_cnt;
|
||||
uint32_t flush_start;
|
||||
uint32_t flush_elaps_sum;
|
||||
uint32_t flush_cnt;
|
||||
uint32_t flush_in_render_start;
|
||||
uint32_t flush_in_render_elaps_sum;
|
||||
uint32_t flush_not_in_render_start;
|
||||
uint32_t flush_not_in_render_elaps_sum;
|
||||
uint32_t render_in_progress : 1;
|
||||
} measured;
|
||||
|
||||
struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user