summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-10-31 09:02:44 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-10-31 09:59:09 -0400
commitee0f23389c694673e8449f03c06a502d85423659 (patch)
tree430eb9d16d000600d0269f44f5b8bcfd22b14b53
parenta2b63846ee5c80014f5bbbe9d4ec51c240c5ac42 (diff)
tests/spec: merge some loops in linear pack tests
Summary: these are small loops, but iterating small loops hundreds of times leads to big slowdowns Reviewers: cedric Reviewed By: cedric Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10567
-rw-r--r--src/tests/elementary/spec/efl_test_pack_linear.c126
1 files changed, 68 insertions, 58 deletions
diff --git a/src/tests/elementary/spec/efl_test_pack_linear.c b/src/tests/elementary/spec/efl_test_pack_linear.c
index 0ecaacd432..ad7644206e 100644
--- a/src/tests/elementary/spec/efl_test_pack_linear.c
+++ b/src/tests/elementary/spec/efl_test_pack_linear.c
@@ -20,15 +20,6 @@
20 spec-meta-end */ 20 spec-meta-end */
21 21
22static void 22static void
23_fill_array(Efl_Ui_Widget *wid[3])
24{
25 for (int i = 0; i < 3; ++i)
26 {
27 wid[i] = create_test_widget();
28 }
29}
30
31static void
32_ordering_equals(Efl_Ui_Widget **wid, unsigned int len) 23_ordering_equals(Efl_Ui_Widget **wid, unsigned int len)
33{ 24{
34 for (unsigned int i = 0; i < len; ++i) 25 for (unsigned int i = 0; i < len; ++i)
@@ -43,10 +34,9 @@ EFL_START_TEST(pack_begin1)
43 Efl_Ui_Widget *wid[3]; 34 Efl_Ui_Widget *wid[3];
44 Efl_Ui_Widget *inv = create_test_widget(); 35 Efl_Ui_Widget *inv = create_test_widget();
45 36
46 _fill_array(wid);
47
48 for (int i = 2; i >= 0; i--) 37 for (int i = 2; i >= 0; i--)
49 { 38 {
39 wid[i] = create_test_widget();
50 efl_pack_begin(widget, wid[i]); 40 efl_pack_begin(widget, wid[i]);
51 ck_assert_ptr_eq(efl_test_parent_get(wid[i]), widget); 41 ck_assert_ptr_eq(efl_test_parent_get(wid[i]), widget);
52 } 42 }
@@ -62,10 +52,9 @@ EFL_START_TEST(pack_begin2)
62{ 52{
63 Efl_Ui_Widget *wid[3]; 53 Efl_Ui_Widget *wid[3];
64 54
65 _fill_array(wid);
66
67 for (int i = 2; i >= 0; i--) 55 for (int i = 2; i >= 0; i--)
68 { 56 {
57 wid[i] = create_test_widget();
69 efl_pack_begin(widget, wid[i]); 58 efl_pack_begin(widget, wid[i]);
70 ck_assert_ptr_eq(efl_test_parent_get(wid[i]), widget); 59 ck_assert_ptr_eq(efl_test_parent_get(wid[i]), widget);
71 } 60 }
@@ -82,10 +71,9 @@ EFL_START_TEST(pack_end1)
82 Efl_Ui_Widget *wid[3]; 71 Efl_Ui_Widget *wid[3];
83 Efl_Ui_Widget *inv = create_test_widget(); 72 Efl_Ui_Widget *inv = create_test_widget();
84 73
85 _fill_array(wid);
86
87 for (int i = 0; i < 3; i++) 74 for (int i = 0; i < 3; i++)
88 { 75 {
76 wid[i] = create_test_widget();
89 efl_pack_end(widget, wid[i]); 77 efl_pack_end(widget, wid[i]);
90 ck_assert_ptr_eq(efl_test_parent_get(wid[i]), widget); 78 ck_assert_ptr_eq(efl_test_parent_get(wid[i]), widget);
91 } 79 }
@@ -102,10 +90,9 @@ EFL_START_TEST(pack_end2)
102{ 90{
103 Efl_Ui_Widget *wid[3]; 91 Efl_Ui_Widget *wid[3];
104 92
105 _fill_array(wid);
106
107 for (int i = 0; i < 3; i++) 93 for (int i = 0; i < 3; i++)
108 { 94 {
95 wid[i] = create_test_widget();
109 efl_pack_end(widget, wid[i]); 96 efl_pack_end(widget, wid[i]);
110 ck_assert_ptr_eq(efl_test_parent_get(wid[i]), widget); 97 ck_assert_ptr_eq(efl_test_parent_get(wid[i]), widget);
111 } 98 }
@@ -122,10 +109,11 @@ EFL_START_TEST(pack_before1)
122 Efl_Ui_Widget *wid[3]; 109 Efl_Ui_Widget *wid[3];
123 Efl_Ui_Widget *inv = create_test_widget(); 110 Efl_Ui_Widget *inv = create_test_widget();
124 111
125 _fill_array(wid);
126
127 for (int i = 0; i < 3; i++) 112 for (int i = 0; i < 3; i++)
128 efl_pack_end(widget, wid[i]); 113 {
114 wid[i] = create_test_widget();
115 efl_pack_end(widget, wid[i]);
116 }
129 117
130 ck_assert_int_eq(efl_pack_before(widget, inv, wid[0]), EINA_TRUE); 118 ck_assert_int_eq(efl_pack_before(widget, inv, wid[0]), EINA_TRUE);
131 ck_assert_ptr_eq(efl_test_parent_get(inv), widget); 119 ck_assert_ptr_eq(efl_test_parent_get(inv), widget);
@@ -145,10 +133,11 @@ EFL_START_TEST(pack_before2)
145 Efl_Ui_Widget *wid[3]; 133 Efl_Ui_Widget *wid[3];
146 Efl_Ui_Widget *inv = create_test_widget(); 134 Efl_Ui_Widget *inv = create_test_widget();
147 135
148 _fill_array(wid);
149
150 for (int i = 0; i < 3; i++) 136 for (int i = 0; i < 3; i++)
151 efl_pack_end(widget, wid[i]); 137 {
138 wid[i] = create_test_widget();
139 efl_pack_end(widget, wid[i]);
140 }
152 141
153 ck_assert_int_eq(efl_pack_before(widget, inv, wid[0]), EINA_TRUE); 142 ck_assert_int_eq(efl_pack_before(widget, inv, wid[0]), EINA_TRUE);
154 ck_assert_ptr_eq(efl_test_parent_get(inv), widget); 143 ck_assert_ptr_eq(efl_test_parent_get(inv), widget);
@@ -167,10 +156,11 @@ EFL_START_TEST(pack_before3)
167 Efl_Ui_Widget *inv = create_test_widget(); 156 Efl_Ui_Widget *inv = create_test_widget();
168 Efl_Ui_Widget *inv2 = create_test_widget(); 157 Efl_Ui_Widget *inv2 = create_test_widget();
169 158
170 _fill_array(wid);
171
172 for (int i = 0; i < 3; i++) 159 for (int i = 0; i < 3; i++)
173 efl_pack_end(widget, wid[i]); 160 {
161 wid[i] = create_test_widget();
162 efl_pack_end(widget, wid[i]);
163 }
174 164
175 EXPECT_ERROR_START; 165 EXPECT_ERROR_START;
176 ck_assert_int_eq(efl_pack_before(widget, inv, inv2), EINA_FALSE); 166 ck_assert_int_eq(efl_pack_before(widget, inv, inv2), EINA_FALSE);
@@ -187,10 +177,11 @@ EFL_START_TEST(pack_before4)
187 Efl_Ui_Widget *wid[3]; 177 Efl_Ui_Widget *wid[3];
188 Efl_Ui_Widget *inv = create_test_widget(); 178 Efl_Ui_Widget *inv = create_test_widget();
189 179
190 _fill_array(wid);
191
192 for (int i = 0; i < 3; i++) 180 for (int i = 0; i < 3; i++)
193 efl_pack_end(widget, wid[i]); 181 {
182 wid[i] = create_test_widget();
183 efl_pack_end(widget, wid[i]);
184 }
194 185
195 ck_assert_int_eq(efl_pack_before(widget, inv, NULL), EINA_TRUE); 186 ck_assert_int_eq(efl_pack_before(widget, inv, NULL), EINA_TRUE);
196 ck_assert_ptr_eq(efl_pack_content_get(widget, 0), inv); 187 ck_assert_ptr_eq(efl_pack_content_get(widget, 0), inv);
@@ -202,10 +193,11 @@ EFL_START_TEST(pack_after1)
202 Efl_Ui_Widget *wid[3]; 193 Efl_Ui_Widget *wid[3];
203 Efl_Ui_Widget *inv = create_test_widget(); 194 Efl_Ui_Widget *inv = create_test_widget();
204 195
205 _fill_array(wid);
206
207 for (int i = 0; i < 3; i++) 196 for (int i = 0; i < 3; i++)
208 efl_pack_end(widget, wid[i]); 197 {
198 wid[i] = create_test_widget();
199 efl_pack_end(widget, wid[i]);
200 }
209 201
210 ck_assert_int_eq(efl_pack_after(widget, inv, wid[0]), EINA_TRUE); 202 ck_assert_int_eq(efl_pack_after(widget, inv, wid[0]), EINA_TRUE);
211 ck_assert_ptr_eq(efl_test_parent_get(inv), widget); 203 ck_assert_ptr_eq(efl_test_parent_get(inv), widget);
@@ -225,10 +217,11 @@ EFL_START_TEST(pack_after2)
225 Efl_Ui_Widget *wid[3]; 217 Efl_Ui_Widget *wid[3];
226 Efl_Ui_Widget *inv = create_test_widget(); 218 Efl_Ui_Widget *inv = create_test_widget();
227 219
228 _fill_array(wid);
229
230 for (int i = 0; i < 3; i++) 220 for (int i = 0; i < 3; i++)
231 efl_pack_end(widget, wid[i]); 221 {
222 wid[i] = create_test_widget();
223 efl_pack_end(widget, wid[i]);
224 }
232 225
233 ck_assert_int_eq(efl_pack_after(widget, inv, wid[0]), EINA_TRUE); 226 ck_assert_int_eq(efl_pack_after(widget, inv, wid[0]), EINA_TRUE);
234 ck_assert_ptr_eq(efl_test_parent_get(inv), widget); 227 ck_assert_ptr_eq(efl_test_parent_get(inv), widget);
@@ -247,10 +240,11 @@ EFL_START_TEST(pack_after3)
247 Efl_Ui_Widget *inv = create_test_widget(); 240 Efl_Ui_Widget *inv = create_test_widget();
248 Efl_Ui_Widget *inv2 = create_test_widget(); 241 Efl_Ui_Widget *inv2 = create_test_widget();
249 242
250 _fill_array(wid);
251
252 for (int i = 0; i < 3; i++) 243 for (int i = 0; i < 3; i++)
253 efl_pack_end(widget, wid[i]); 244 {
245 wid[i] = create_test_widget();
246 efl_pack_end(widget, wid[i]);
247 }
254 248
255 EXPECT_ERROR_START; 249 EXPECT_ERROR_START;
256 ck_assert_int_eq(efl_pack_after(widget, inv, inv2), EINA_FALSE); 250 ck_assert_int_eq(efl_pack_after(widget, inv, inv2), EINA_FALSE);
@@ -267,10 +261,11 @@ EFL_START_TEST(pack_after4)
267 Efl_Ui_Widget *wid[3]; 261 Efl_Ui_Widget *wid[3];
268 Efl_Ui_Widget *inv = create_test_widget(); 262 Efl_Ui_Widget *inv = create_test_widget();
269 263
270 _fill_array(wid);
271
272 for (int i = 0; i < 3; i++) 264 for (int i = 0; i < 3; i++)
273 efl_pack_end(widget, wid[i]); 265 {
266 wid[i] = create_test_widget();
267 efl_pack_end(widget, wid[i]);
268 }
274 269
275 ck_assert_int_eq(efl_pack_after(widget, inv, NULL), EINA_TRUE); 270 ck_assert_int_eq(efl_pack_after(widget, inv, NULL), EINA_TRUE);
276 ck_assert_ptr_eq(efl_pack_content_get(widget, 3), inv); 271 ck_assert_ptr_eq(efl_pack_content_get(widget, 3), inv);
@@ -285,9 +280,11 @@ EFL_START_TEST(pack_at1)
285 Efl_Ui_Widget *inv = create_test_widget(); 280 Efl_Ui_Widget *inv = create_test_widget();
286 unsigned int i; 281 unsigned int i;
287 282
288 _fill_array(wid);
289 for (int i = 0; i < 3; i++) 283 for (int i = 0; i < 3; i++)
290 efl_pack_end(widget, wid[i]); 284 {
285 wid[i] = create_test_widget();
286 efl_pack_end(widget, wid[i]);
287 }
291 288
292 efl_pack_at(widget, inv, x); 289 efl_pack_at(widget, inv, x);
293 ck_assert_ptr_eq(efl_test_parent_get(inv), widget); 290 ck_assert_ptr_eq(efl_test_parent_get(inv), widget);
@@ -316,9 +313,11 @@ EFL_START_TEST(pack_at2)
316 Efl_Ui_Widget *inv = create_test_widget(); 313 Efl_Ui_Widget *inv = create_test_widget();
317 unsigned int i; 314 unsigned int i;
318 315
319 _fill_array(wid);
320 for (int i = 0; i < 3; i++) 316 for (int i = 0; i < 3; i++)
321 efl_pack_end(widget, wid[i]); 317 {
318 wid[i] = create_test_widget();
319 efl_pack_end(widget, wid[i]);
320 }
322 321
323 ck_assert_int_eq(efl_pack_at(widget, inv, x), EINA_TRUE); 322 ck_assert_int_eq(efl_pack_at(widget, inv, x), EINA_TRUE);
324 ck_assert_ptr_eq(efl_test_parent_get(inv), widget); 323 ck_assert_ptr_eq(efl_test_parent_get(inv), widget);
@@ -350,9 +349,11 @@ EFL_START_TEST(pack_at3)
350 Efl_Ui_Widget *inv = create_test_widget(); 349 Efl_Ui_Widget *inv = create_test_widget();
351 Efl_Ui_Widget *inv2 = create_test_widget(); 350 Efl_Ui_Widget *inv2 = create_test_widget();
352 351
353 _fill_array(wid);
354 for (int i = 0; i < 3; i++) 352 for (int i = 0; i < 3; i++)
355 efl_pack_end(widget, wid[i]); 353 {
354 wid[i] = create_test_widget();
355 efl_pack_end(widget, wid[i]);
356 }
356 357
357 ck_assert_int_eq(efl_pack_at(widget, inv,-100000), EINA_TRUE); 358 ck_assert_int_eq(efl_pack_at(widget, inv,-100000), EINA_TRUE);
358 ck_assert_ptr_eq(efl_test_parent_get(inv), widget); 359 ck_assert_ptr_eq(efl_test_parent_get(inv), widget);
@@ -367,10 +368,11 @@ EFL_START_TEST(pack_content_get1)
367{ 368{
368 Efl_Ui_Widget *wid[3]; 369 Efl_Ui_Widget *wid[3];
369 370
370 _fill_array(wid);
371
372 for (int i = 0; i < 3; i++) 371 for (int i = 0; i < 3; i++)
373 efl_pack_end(widget, wid[i]); 372 {
373 wid[i] = create_test_widget();
374 efl_pack_end(widget, wid[i]);
375 }
374 376
375 for (int i = -100000; i <= 100000; i++) 377 for (int i = -100000; i <= 100000; i++)
376 { 378 {
@@ -389,9 +391,11 @@ EFL_START_TEST(pack_index_get1)
389 Efl_Ui_Widget *wid[3]; 391 Efl_Ui_Widget *wid[3];
390 Efl_Ui_Widget *inv = create_test_widget(); 392 Efl_Ui_Widget *inv = create_test_widget();
391 393
392 _fill_array(wid);
393 for (int i = 0; i < 3; i++) 394 for (int i = 0; i < 3; i++)
394 efl_pack_end(widget, wid[i]); 395 {
396 wid[i] = create_test_widget();
397 efl_pack_end(widget, wid[i]);
398 }
395 for (int i = 0; i < 3; i++) 399 for (int i = 0; i < 3; i++)
396 ck_assert_int_eq(efl_pack_index_get(widget, wid[i]), i); 400 ck_assert_int_eq(efl_pack_index_get(widget, wid[i]), i);
397 401
@@ -404,9 +408,11 @@ EFL_START_TEST(pack_unpack_at1)
404{ 408{
405 Efl_Ui_Widget *wid[3]; 409 Efl_Ui_Widget *wid[3];
406 410
407 _fill_array(wid);
408 for (int i = 0; i < 3; i++) 411 for (int i = 0; i < 3; i++)
409 efl_pack_end(widget, wid[i]); 412 {
413 wid[i] = create_test_widget();
414 efl_pack_end(widget, wid[i]);
415 }
410 for (int i = 0; i < 3; i++) 416 for (int i = 0; i < 3; i++)
411 ck_assert_int_eq(efl_pack_index_get(widget, wid[i]), i); 417 ck_assert_int_eq(efl_pack_index_get(widget, wid[i]), i);
412 418
@@ -427,9 +433,11 @@ EFL_START_TEST(pack_unpack_at2)
427{ 433{
428 Efl_Ui_Widget *wid[3]; 434 Efl_Ui_Widget *wid[3];
429 435
430 _fill_array(wid);
431 for (int i = 0; i < 3; i++) 436 for (int i = 0; i < 3; i++)
432 efl_pack_end(widget, wid[i]); 437 {
438 wid[i] = create_test_widget();
439 efl_pack_end(widget, wid[i]);
440 }
433 for (int i = 0; i < 3; i++) 441 for (int i = 0; i < 3; i++)
434 ck_assert_int_eq(efl_pack_index_get(widget, wid[i]), i); 442 ck_assert_int_eq(efl_pack_index_get(widget, wid[i]), i);
435 443
@@ -446,9 +454,11 @@ EFL_START_TEST(pack_unpack_at3)
446 { 454 {
447 Efl_Ui_Widget *wid[3]; 455 Efl_Ui_Widget *wid[3];
448 456
449 _fill_array(wid);
450 for (int i = 0; i < 3; i++) 457 for (int i = 0; i < 3; i++)
451 efl_pack_end(widget, wid[i]); 458 {
459 wid[i] = create_test_widget();
460 efl_pack_end(widget, wid[i]);
461 }
452 ck_assert_ptr_eq(efl_pack_unpack_at(widget, x), wid[(3+x)%3]); 462 ck_assert_ptr_eq(efl_pack_unpack_at(widget, x), wid[(3+x)%3]);
453 ck_assert_int_eq(efl_content_count(widget), 2); 463 ck_assert_int_eq(efl_content_count(widget), 2);
454 ck_assert_ptr_ne(efl_test_parent_get(wid[(3+x)%3]), widget); 464 ck_assert_ptr_ne(efl_test_parent_get(wid[(3+x)%3]), widget);