summaryrefslogtreecommitdiff
path: root/src/benchmarks
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-18 13:51:30 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-21 07:50:54 +0200
commit8520c648b36d8568dcf37b4f4b3458ceb5116ae1 (patch)
tree57a440b5487dc5bfd9ae679a12a0872f204c1f6d /src/benchmarks
parent3cb3c1c4b1173d5f6cb296c150352db798a3b919 (diff)
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
Diffstat (limited to 'src/benchmarks')
-rw-r--r--src/benchmarks/elementary/collection.c (renamed from src/benchmarks/elementary/item_container.c)120
-rw-r--r--src/benchmarks/elementary/meson.build4
2 files changed, 101 insertions, 23 deletions
diff --git a/src/benchmarks/elementary/item_container.c b/src/benchmarks/elementary/collection.c
index 982df1d..bbb0990 100644
--- a/src/benchmarks/elementary/item_container.c
+++ b/src/benchmarks/elementary/collection.c
@@ -1,5 +1,7 @@
1#include <Efl_Ui.h> 1#include <Efl_Ui.h>
2 2
3static Efl_Ui_Win *win;
4static Efl_Ui_Collection *collection;
3static Eo *first, *last, *middle; 5static Eo *first, *last, *middle;
4static int timer = 15; 6static int timer = 15;
5static int frames = 0; 7static int frames = 0;
@@ -60,41 +62,117 @@ _first_frame_cb(void *data, const Efl_Event *ev EINA_UNUSED)
60 efl_event_callback_del(ev->object, EFL_CANVAS_SCENE_EVENT_RENDER_POST, _first_frame_cb, data); 62 efl_event_callback_del(ev->object, EFL_CANVAS_SCENE_EVENT_RENDER_POST, _first_frame_cb, data);
61} 63}
62 64
63EAPI_MAIN void 65static void
64efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED) 66_build_list(int items)
65{ 67{
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 68
74 list = efl_new(EFL_UI_POSITION_MANAGER_LIST_CLASS); 69 collection = efl_add(EFL_UI_LIST_CLASS, win);
75 item_container = efl_add(EFL_UI_COLLECTION_CLASS, win, 70 efl_content_set(win, collection);
76 efl_ui_collection_position_manager_set(efl_added, list));
77 efl_content_set(win, item_container);
78 71
79 printf("Building 5000 objects\n"); 72 for (int i = 0; i < items; ++i)
80 for (int i = 0; i < 5000; ++i)
81 { 73 {
82 Eo *il = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container); 74 Eo *il = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, collection);
83 double r = 10+((double)190/(double)10)*(i%10); 75 double r = 10+((double)190/(double)10)*(i%10);
84 76
85 if (i == 0) 77 if (i == 0)
86 first = il; 78 first = il;
87 else if (i == 2500) 79 else if (i == items/2)
88 middle = il; 80 middle = il;
89 else if (i == 4999) 81 else if (i == (items - 1))
90 last = il; 82 last = il;
91 efl_gfx_color_set(il, r, 10, 10, 255); 83 efl_gfx_color_set(il, r, 10, 10, 255);
92 efl_gfx_hint_size_min_set(il, EINA_SIZE2D(40, 40+(i%2)*40)); 84 efl_gfx_hint_size_min_set(il, EINA_SIZE2D(40, 40+(i%2)*40));
93 efl_pack_end(item_container, il); 85 efl_pack_end(collection, il);
94 } 86 }
87}
88
89static void
90_build_grid(int items)
91{
92 Eo *list;
93
94 collection = efl_add(EFL_UI_GRID_CLASS, win);
95 efl_content_set(win, collection);
96
97 for (int i = 0; i < items; ++i)
98 {
99 Eo *il = efl_add(EFL_UI_GRID_DEFAULT_ITEM_CLASS, collection);
100 double r = 10+((double)190/(double)10)*(i%10);
101
102 if (i == 0)
103 first = il;
104 else if (i == items/2)
105 middle = il;
106 else if (i == (items - 1))
107 last = il;
108 efl_gfx_color_set(il, r, 10, 10, 255);
109 efl_gfx_hint_size_min_set(il, EINA_SIZE2D(80, 150+(i%2)*40));
110 efl_pack_end(collection, il);
111 }
112}
113
114static void
115print_help(void)
116{
117 printf("The following options are optional:\n");
118 printf(" --list Run the benchmark with the list position manager.\n");
119 printf(" --grid Run the benchmark with the list position manager.\n");
120 printf(" --items X Run the benchmark with X items.\n");
121}
122
123EAPI_MAIN void
124efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
125{
126 Eina_Accessor *cml;
127 const char *part;
128 int c;
129 int items = 5000;
130 Eina_Bool grid = EINA_FALSE;
131
132 printf("Started on pid: %d\n", getpid());
133
134 cml = efl_core_command_line_command_access(efl_main_loop_get());
135
136 EINA_ACCESSOR_FOREACH(cml, c, part)
137 {
138 if (c == 0) continue;
139 if (eina_streq(part, "--items"))
140 {
141 c++;
142 EINA_SAFETY_ON_FALSE_GOTO(eina_accessor_data_get(cml, c, (void**)&part), err);
143 items = atoi(part);
144 if (!items)
145 goto err;
146 }
147 else if (eina_streq(part, "--list"))
148 {
149 grid = EINA_FALSE;
150 }
151 else if (eina_streq(part, "--grid"))
152 {
153 grid = EINA_TRUE;
154 }
155 else
156 goto err;
157 }
158
159 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
160 efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
161 efl_text_set(efl_added, "Efl.Ui.Item_Container benchmark"),
162 efl_ui_win_autodel_set(efl_added, EINA_TRUE)
163 );
164 printf("Building %d objects\n", items);
165 if (grid)
166 _build_grid(items);
167 else
168 _build_list(items);
95 printf("Done!\n"); 169 printf("Done!\n");
96 efl_gfx_entity_size_set(win, EINA_SIZE2D(200, 200)); 170 efl_gfx_entity_size_set(win, EINA_SIZE2D(500, 500));
97 171
98 efl_event_callback_add(evas_object_evas_get(win), EFL_CANVAS_SCENE_EVENT_RENDER_POST, _first_frame_cb, item_container); 172 efl_event_callback_add(evas_object_evas_get(win), EFL_CANVAS_SCENE_EVENT_RENDER_POST, _first_frame_cb, collection);
173 return;
174err:
175 print_help();
176 efl_exit(-1);
99} 177}
100EFL_MAIN() 178EFL_MAIN()
diff --git a/src/benchmarks/elementary/meson.build b/src/benchmarks/elementary/meson.build
index af71b97..6685ffc 100644
--- a/src/benchmarks/elementary/meson.build
+++ b/src/benchmarks/elementary/meson.build
@@ -7,8 +7,8 @@ benchmark('focus_widget_tree', focus_widget_tree_bench,
7 args: ['5'], 7 args: ['5'],
8) 8)
9 9
10item_container = executable('item_container', 10item_container = executable('collection',
11 'item_container.c', 11 'collection.c',
12 dependencies: [elementary, ecore_input_evas, eio], 12 dependencies: [elementary, ecore_input_evas, eio],
13) 13)
14 14