forked from enlightenment/efl
replace item_container benchmark
the new one has the correct name, can test grid and list, has a changable amount of items. Additionally, it prints the pid on startup, which is usefull for perf related debugging. Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9609
This commit is contained in:
parent
3cb3c1c4b1
commit
8520c648b3
|
@ -1,5 +1,7 @@
|
||||||
#include <Efl_Ui.h>
|
#include <Efl_Ui.h>
|
||||||
|
|
||||||
|
static Efl_Ui_Win *win;
|
||||||
|
static Efl_Ui_Collection *collection;
|
||||||
static Eo *first, *last, *middle;
|
static Eo *first, *last, *middle;
|
||||||
static int timer = 15;
|
static int timer = 15;
|
||||||
static int frames = 0;
|
static int frames = 0;
|
||||||
|
@ -60,41 +62,117 @@ _first_frame_cb(void *data, const Efl_Event *ev EINA_UNUSED)
|
||||||
efl_event_callback_del(ev->object, EFL_CANVAS_SCENE_EVENT_RENDER_POST, _first_frame_cb, data);
|
efl_event_callback_del(ev->object, EFL_CANVAS_SCENE_EVENT_RENDER_POST, _first_frame_cb, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_build_list(int items)
|
||||||
|
{
|
||||||
|
|
||||||
|
collection = efl_add(EFL_UI_LIST_CLASS, win);
|
||||||
|
efl_content_set(win, collection);
|
||||||
|
|
||||||
|
for (int i = 0; i < items; ++i)
|
||||||
|
{
|
||||||
|
Eo *il = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, collection);
|
||||||
|
double r = 10+((double)190/(double)10)*(i%10);
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
first = il;
|
||||||
|
else if (i == items/2)
|
||||||
|
middle = il;
|
||||||
|
else if (i == (items - 1))
|
||||||
|
last = il;
|
||||||
|
efl_gfx_color_set(il, r, 10, 10, 255);
|
||||||
|
efl_gfx_hint_size_min_set(il, EINA_SIZE2D(40, 40+(i%2)*40));
|
||||||
|
efl_pack_end(collection, il);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_build_grid(int items)
|
||||||
|
{
|
||||||
|
Eo *list;
|
||||||
|
|
||||||
|
collection = efl_add(EFL_UI_GRID_CLASS, win);
|
||||||
|
efl_content_set(win, collection);
|
||||||
|
|
||||||
|
for (int i = 0; i < items; ++i)
|
||||||
|
{
|
||||||
|
Eo *il = efl_add(EFL_UI_GRID_DEFAULT_ITEM_CLASS, collection);
|
||||||
|
double r = 10+((double)190/(double)10)*(i%10);
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
first = il;
|
||||||
|
else if (i == items/2)
|
||||||
|
middle = il;
|
||||||
|
else if (i == (items - 1))
|
||||||
|
last = il;
|
||||||
|
efl_gfx_color_set(il, r, 10, 10, 255);
|
||||||
|
efl_gfx_hint_size_min_set(il, EINA_SIZE2D(80, 150+(i%2)*40));
|
||||||
|
efl_pack_end(collection, il);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_help(void)
|
||||||
|
{
|
||||||
|
printf("The following options are optional:\n");
|
||||||
|
printf(" --list Run the benchmark with the list position manager.\n");
|
||||||
|
printf(" --grid Run the benchmark with the list position manager.\n");
|
||||||
|
printf(" --items X Run the benchmark with X items.\n");
|
||||||
|
}
|
||||||
|
|
||||||
EAPI_MAIN void
|
EAPI_MAIN void
|
||||||
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
|
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Eo *win, *item_container, *list;
|
Eina_Accessor *cml;
|
||||||
|
const char *part;
|
||||||
|
int c;
|
||||||
|
int items = 5000;
|
||||||
|
Eina_Bool grid = EINA_FALSE;
|
||||||
|
|
||||||
|
printf("Started on pid: %d\n", getpid());
|
||||||
|
|
||||||
|
cml = efl_core_command_line_command_access(efl_main_loop_get());
|
||||||
|
|
||||||
|
EINA_ACCESSOR_FOREACH(cml, c, part)
|
||||||
|
{
|
||||||
|
if (c == 0) continue;
|
||||||
|
if (eina_streq(part, "--items"))
|
||||||
|
{
|
||||||
|
c++;
|
||||||
|
EINA_SAFETY_ON_FALSE_GOTO(eina_accessor_data_get(cml, c, (void**)&part), err);
|
||||||
|
items = atoi(part);
|
||||||
|
if (!items)
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
else if (eina_streq(part, "--list"))
|
||||||
|
{
|
||||||
|
grid = EINA_FALSE;
|
||||||
|
}
|
||||||
|
else if (eina_streq(part, "--grid"))
|
||||||
|
{
|
||||||
|
grid = EINA_TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
|
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
|
||||||
efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
|
efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
|
||||||
efl_text_set(efl_added, "Efl.Ui.Item_Container benchmark"),
|
efl_text_set(efl_added, "Efl.Ui.Item_Container benchmark"),
|
||||||
efl_ui_win_autodel_set(efl_added, EINA_TRUE)
|
efl_ui_win_autodel_set(efl_added, EINA_TRUE)
|
||||||
);
|
);
|
||||||
|
printf("Building %d objects\n", items);
|
||||||
list = efl_new(EFL_UI_POSITION_MANAGER_LIST_CLASS);
|
if (grid)
|
||||||
item_container = efl_add(EFL_UI_COLLECTION_CLASS, win,
|
_build_grid(items);
|
||||||
efl_ui_collection_position_manager_set(efl_added, list));
|
else
|
||||||
efl_content_set(win, item_container);
|
_build_list(items);
|
||||||
|
|
||||||
printf("Building 5000 objects\n");
|
|
||||||
for (int i = 0; i < 5000; ++i)
|
|
||||||
{
|
|
||||||
Eo *il = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
|
|
||||||
double r = 10+((double)190/(double)10)*(i%10);
|
|
||||||
|
|
||||||
if (i == 0)
|
|
||||||
first = il;
|
|
||||||
else if (i == 2500)
|
|
||||||
middle = il;
|
|
||||||
else if (i == 4999)
|
|
||||||
last = il;
|
|
||||||
efl_gfx_color_set(il, r, 10, 10, 255);
|
|
||||||
efl_gfx_hint_size_min_set(il, EINA_SIZE2D(40, 40+(i%2)*40));
|
|
||||||
efl_pack_end(item_container, il);
|
|
||||||
}
|
|
||||||
printf("Done!\n");
|
printf("Done!\n");
|
||||||
efl_gfx_entity_size_set(win, EINA_SIZE2D(200, 200));
|
efl_gfx_entity_size_set(win, EINA_SIZE2D(500, 500));
|
||||||
|
|
||||||
efl_event_callback_add(evas_object_evas_get(win), EFL_CANVAS_SCENE_EVENT_RENDER_POST, _first_frame_cb, item_container);
|
efl_event_callback_add(evas_object_evas_get(win), EFL_CANVAS_SCENE_EVENT_RENDER_POST, _first_frame_cb, collection);
|
||||||
|
return;
|
||||||
|
err:
|
||||||
|
print_help();
|
||||||
|
efl_exit(-1);
|
||||||
}
|
}
|
||||||
EFL_MAIN()
|
EFL_MAIN()
|
|
@ -7,8 +7,8 @@ benchmark('focus_widget_tree', focus_widget_tree_bench,
|
||||||
args: ['5'],
|
args: ['5'],
|
||||||
)
|
)
|
||||||
|
|
||||||
item_container = executable('item_container',
|
item_container = executable('collection',
|
||||||
'item_container.c',
|
'collection.c',
|
||||||
dependencies: [elementary, ecore_input_evas, eio],
|
dependencies: [elementary, ecore_input_evas, eio],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue