forked from lc-soft/LCUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_widget.c
60 lines (52 loc) · 1.6 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
#include <LCUI_Build.h>
#include <LCUI/LCUI.h>
#include <LCUI/font.h>
#include <LCUI/gui/widget.h>
#include <LCUI/gui/widget/textview.h>
#include <LCUI/util/logger.h>
#include <stdio.h>
#include <time.h>
#include "test.h"
int main(void)
{
clock_t c;
size_t i, n = 100000;
double sec;
LCUI_Widget box, w;
LCUI_InitFontLibrary();
LCUI_InitWidget();
box = LCUIWidget_New(NULL);
c = clock();
Logger_Debug("start create %zu widgets...\n", n);
Widget_Append(LCUIWidget_GetRoot(), box);
for (i = 0; i < n; ++i) {
w = LCUIWidget_New("textview");
TextView_SetTextW(w, L"hello, test");
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();
LCUIWidget_Update();
LCUIWidget_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();
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();
LCUIWidget_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");
LCUI_FreeWidget();
LCUI_FreeFontLibrary();
return 0;
}