Files
LCUI/test/test_widget.c
T
YDYKand李梓豪 b46306ddea refactor(util): add yutil library (#264)
* add yutil

* add yutil to util.h

* remove util file that same as yutil's

* replace the old header file like '#include <LCUI/util/*>' with yutil's head file

* Replace the old UTIL module associated data structures and function call code

* change timer

* Replace the old UTIL module associated data structures and function call code

* fix

* fix compilation problems(RGB to YUTIL_TEST_RGB)

* turn some useless changes back to origin

* change YUTIL_TEST_RGB back to RGB and add  lcui-util/xmake.lua include

* update github action

* update github action

* update github action

* change new yutil func name

* update xmake and change way to include yutil

* update include to <yutil.h>

* update list_for_each to for(list_each())

* fix

* add graph.h to test_*

* add #include <LCUI/graph.h>

* update yutil

* change timer func name and update submodule

* update submodules

* test strncpy

* turn useless code back origin

* fix lose RGB issue

* fix yutil charset

* update yutil

* update yutil

* add yutil_test instead of lcui-util test

* change timer func name style

Co-authored-by: 李梓豪 <yidianyiko@foxmail.com>
2023-04-01 22:34:33 +08:00

60 lines
1.6 KiB
C

#include <stdio.h>
#include <time.h>
#include <LCUI.h>
#include <LCUI/font.h>
#include <LCUI/gui/widget.h>
#include <LCUI/gui/widget/textview.h>
#include <yutil.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;
}