forked from lc-soft/LCUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_widget.c
65 lines (56 loc) · 1.67 KB
/
test_widget.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* tests/test_widget.c
*
* Copyright (c) 2023, Liu Chao <i@lc-soft.io> All rights reserved.
*
* SPDX-License-Identifier: MIT
*
* This file is part of LCUI, distributed under the MIT License found in the
* LICENSE.TXT file in the root directory of this source tree.
*/
#include <stdio.h>
#include <time.h>
#include <ui.h>
#include <LCUI/widgets/text.h>
int main(void)
{
clock_t c;
size_t i, n = 100000;
double sec;
ui_widget_t *box, *w;
ui_init();
box = ui_create_widget(NULL);
c = clock();
logger_debug("start create %zu widgets...\n", n);
ui_widget_append(ui_root(), box);
for (i = 0; i < n; ++i) {
w = ui_create_widget("text");
ui_text_set_content_w(w, L"hello, test");
ui_widget_append(box, w);
}
sec = (clock() - c) * 1.0 / CLOCKS_PER_SEC;
logger_debug("%zu widgets have been created, which took %gs\n", n, sec);
logger_debug("it should take less than 1s\n");
logger_debug("start update %zu widgets...\n", n);
c = clock();
ui_update();
ui_update();
sec = (clock() - c) * 1.0 / CLOCKS_PER_SEC;
logger_debug("%zu widgets have been updated, which took %gs\n", n, sec);
logger_debug("it should take less than 6s\n");
logger_debug("start remove %zu widgets...\n", n);
c = clock();
ui_widget_empty(box);
sec = (clock() - c) * 1.0 / CLOCKS_PER_SEC;
logger_debug("%zu widgets have been removed, which took %gs\n", n, sec);
logger_debug("it should take less than 0.5s\n");
logger_debug("start destroy %zu widgets...\n", n);
c = clock();
ui_update();
sec = (clock() - c) * 1.0 / CLOCKS_PER_SEC;
logger_debug("%zu widgets have been destroyed, which took %gs\n", n,
sec);
logger_debug("it should take less than 1s\n");
ui_destroy();
return 0;
}