summaryrefslogtreecommitdiff
path: root/src/benchmarks
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-06-29 16:19:08 +0200
committerCedric BAIL <cedric.bail@free.fr>2019-07-24 10:38:22 -0700
commit577b82dad69c7f07856cbb254fcc60aab6f90999 (patch)
tree6292ee6c022553d826026362f33fc692f8f67e2c /src/benchmarks
parent0cd5427c3f556135fffff79193fb03de6036eab4 (diff)
Introduce Efl.Ui.Item_Container
this is a new widget which aims to replace Efl.Ui.Grid / Efl.Ui.List. The widget is split up in a widget and a interface for item placement. Efl_Ui_Item_Position_Manager: The interface contains API which is used by the Item_Container to place the items, there is also a set of common tests which tests for the casual tripping wires, and ensures that the events are emitted in the correct moments (the later part still can be improved) Efl_Ui_Item_Container: The widget itself, it contains the API for the enduser to add Items to the widget, it handles the different modes for selection type and emits the events for selection changes. The pack API is conform with the spec unit test. An additional set of tests is defined which should be able to be run on every widget with a specific position_manager beeing set. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9285
Diffstat (limited to 'src/benchmarks')
-rw-r--r--src/benchmarks/elementary/item_container.c100
-rw-r--r--src/benchmarks/elementary/meson.build7
2 files changed, 107 insertions, 0 deletions
diff --git a/src/benchmarks/elementary/item_container.c b/src/benchmarks/elementary/item_container.c
new file mode 100644
index 0000000..b93004c
--- /dev/null
+++ b/src/benchmarks/elementary/item_container.c
@@ -0,0 +1,100 @@
1#include <Efl_Ui.h>
2
3static Eo *first, *last, *middle;
4static int timer = 15;
5static int frames = 0;
6static double start_time;
7
8static void
9_timer_tick(void *data, const Efl_Event *ev)
10{
11 if (timer % 2 == 0)
12 {
13 efl_ui_item_container_item_scroll(data, last, EINA_TRUE);
14 }
15 else
16 {
17 efl_ui_item_container_item_scroll(data, first, EINA_TRUE);
18 }
19
20 timer--;
21
22 if (timer == 0)
23 {
24 double runtime = ecore_time_get() - start_time;
25 efl_loop_quit(efl_app_main_get(), EINA_VALUE_EMPTY);
26 efl_del(ev->object);
27 printf("We did %d frames in %f s seconds\n", frames, runtime);
28 printf("FPS: %f\n", ((double)frames / runtime));
29
30 }
31}
32
33static void
34_caputure(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
35{
36 frames ++;
37}
38
39static void
40_started_cb(void *data, const Efl_Event *ev EINA_UNUSED)
41{
42 efl_add(EFL_LOOP_TIMER_CLASS, efl_main_loop_get(),
43 efl_loop_timer_interval_set(efl_added, 1.0),
44 efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TIMER_TICK, _timer_tick, data)
45 );
46 start_time = ecore_time_get();
47 efl_event_callback_add(evas_object_evas_get(data), EFL_CANVAS_SCENE_EVENT_RENDER_POST, _caputure, data);
48 efl_del(ev->object);
49}
50
51static void
52_first_frame_cb(void *data, const Efl_Event *ev EINA_UNUSED)
53{
54 efl_ui_item_container_item_scroll(data, middle, EINA_FALSE);
55 //give time to stabelize
56 efl_add(EFL_LOOP_TIMER_CLASS, efl_main_loop_get(),
57 efl_loop_timer_interval_set(efl_added, 15.0),
58 efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TIMER_TICK, _started_cb, data)
59 );
60 efl_event_callback_del(ev->object, EFL_CANVAS_SCENE_EVENT_RENDER_POST, _first_frame_cb, data);
61}
62
63EAPI_MAIN void
64efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
65{
66 Eo *win, *item_container, *list;
67
68 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
69 efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
70 efl_text_set(efl_added, "Efl.Ui.Item_Container benchmark"),
71 efl_ui_win_autodel_set(efl_added, EINA_TRUE)
72 );
73
74 list = efl_new(EFL_UI_LIST_POSITION_MANAGER_CLASS);
75 item_container = efl_add(EFL_UI_ITEM_CONTAINER_CLASS, win,
76 efl_ui_item_container_position_manager_set(efl_added, list));
77 efl_content_set(win, item_container);
78
79 printf("Building 5000 objects\n");
80 for (int i = 0; i < 5000; ++i)
81 {
82 Eo *il = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
83 double r = 10+((double)190/(double)10)*(i%10);
84
85 if (i == 0)
86 first = il;
87 else if (i == 2500)
88 middle = il;
89 else if (i == 4999)
90 last = il;
91 efl_gfx_color_set(il, r, 10, 10, 255);
92 efl_gfx_hint_size_min_set(il, EINA_SIZE2D(40, 40+(i%2)*40));
93 efl_pack_end(item_container, il);
94 }
95 printf("Done!\n");
96 efl_gfx_entity_size_set(win, EINA_SIZE2D(200, 200));
97
98 efl_event_callback_add(evas_object_evas_get(win), EFL_CANVAS_SCENE_EVENT_RENDER_POST, _first_frame_cb, item_container);
99}
100EFL_MAIN()
diff --git a/src/benchmarks/elementary/meson.build b/src/benchmarks/elementary/meson.build
index 206ea06..af71b97 100644
--- a/src/benchmarks/elementary/meson.build
+++ b/src/benchmarks/elementary/meson.build
@@ -6,3 +6,10 @@ focus_widget_tree_bench = executable('focus_widget_tree_bench',
6benchmark('focus_widget_tree', focus_widget_tree_bench, 6benchmark('focus_widget_tree', focus_widget_tree_bench,
7 args: ['5'], 7 args: ['5'],
8) 8)
9
10item_container = executable('item_container',
11 'item_container.c',
12 dependencies: [elementary, ecore_input_evas, eio],
13)
14
15benchmark('item_container', item_container)