slot 0.0.1
A real time UI render framework
载入中...
搜索中...
未找到
宏定义 | 函数
YGBenchmark.c 文件参考
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <yoga/Yoga.h>
YGBenchmark.c 的引用(Include)关系图:

宏定义

#define NUM_REPETITIONS   1000
 
#define YGBENCHMARKS(BLOCK)
 
#define YGBENCHMARK(NAME, BLOCK)
 

函数

static int __compareDoubles (const void *a, const void *b)
 
static void __printBenchmarkResult (char *name, clock_t start, const clock_t *endTimes)
 
static YGSize _measure (YGNodeConstRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode)
 
 YGBENCHMARKS ({ YGBENCHMARK("Stack with flex", { const YGNodeRef root=YGNodeNew();YGNodeStyleSetWidth(root, 100);YGNodeStyleSetHeight(root, 100);for(uint32_t i=0;i< 10;i++) { const YGNodeRef child=YGNodeNew();YGNodeSetMeasureFunc(child, _measure);YGNodeStyleSetFlex(child, 1);YGNodeInsertChild(root, child, 0);} YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);YGNodeFreeRecursive(root);});YGBENCHMARK("Align stretch in undefined axis", { const YGNodeRef root=YGNodeNew();for(uint32_t i=0;i< 10;i++) { const YGNodeRef child=YGNodeNew();YGNodeStyleSetHeight(child, 20);YGNodeSetMeasureFunc(child, _measure);YGNodeInsertChild(root, child, 0);} YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);YGNodeFreeRecursive(root);});YGBENCHMARK("Nested flex", { const YGNodeRef root=YGNodeNew();for(uint32_t i=0;i< 10;i++) { const YGNodeRef child=YGNodeNew();YGNodeStyleSetFlex(child, 1);YGNodeInsertChild(root, child, 0);for(uint32_t ii=0;ii< 10;ii++) { const YGNodeRef grandChild=YGNodeNew();YGNodeSetMeasureFunc(grandChild, _measure);YGNodeStyleSetFlex(grandChild, 1);YGNodeInsertChild(child, grandChild, 0);} } YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);YGNodeFreeRecursive(root);});YGBENCHMARK("Huge nested layout", { const YGNodeRef root=YGNodeNew();for(uint32_t i=0;i< 10;i++) { const YGNodeRef child=YGNodeNew();YGNodeStyleSetFlexGrow(child, 1);YGNodeStyleSetWidth(child, 10);YGNodeStyleSetHeight(child, 10);YGNodeInsertChild(root, child, 0);for(uint32_t ii=0;ii< 10;ii++) { const YGNodeRef grandChild=YGNodeNew();YGNodeStyleSetFlexDirection(grandChild, YGFlexDirectionRow);YGNodeStyleSetFlexGrow(grandChild, 1);YGNodeStyleSetWidth(grandChild, 10);YGNodeStyleSetHeight(grandChild, 10);YGNodeInsertChild(child, grandChild, 0);for(uint32_t iii=0;iii< 10;iii++) { const YGNodeRef grandGrandChild=YGNodeNew();YGNodeStyleSetFlexGrow(grandGrandChild, 1);YGNodeStyleSetWidth(grandGrandChild, 10);YGNodeStyleSetHeight(grandGrandChild, 10);YGNodeInsertChild(grandChild, grandGrandChild, 0);for(uint32_t iiii=0;iiii< 10;iiii++) { const YGNodeRef grandGrandGrandChild=YGNodeNew();YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow);YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1);YGNodeStyleSetWidth(grandGrandGrandChild, 10);YGNodeStyleSetHeight(grandGrandGrandChild, 10);YGNodeInsertChild(grandGrandChild, grandGrandGrandChild, 0);} } } } YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);YGNodeFreeRecursive(root);});})
 

宏定义说明

◆ NUM_REPETITIONS

#define NUM_REPETITIONS   1000

◆ YGBENCHMARK

#define YGBENCHMARK ( NAME,
BLOCK )
值:
__start = clock(); \
for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \
{BLOCK} __endTimes[__i] = clock(); \
} \
__printBenchmarkResult(NAME, __start, __endTimes);
#define NUM_REPETITIONS
Definition YGBenchmark.c:16

◆ YGBENCHMARKS

#define YGBENCHMARKS ( BLOCK)
值:
int main(int argc, char const* argv[]) { \
(void)argc; \
(void)argv; \
clock_t __start; \
clock_t __endTimes[NUM_REPETITIONS]; \
{ \
BLOCK \
} \
return 0; \
}
int main(int argc, char *argv[])
Definition Benchmark.cpp:390

函数说明

◆ __compareDoubles()

static int __compareDoubles ( const void * a,
const void * b )
static
这是这个函数的调用关系图:

◆ __printBenchmarkResult()

static void __printBenchmarkResult ( char * name,
clock_t start,
const clock_t * endTimes )
static
函数调用图:

◆ _measure()

static YGSize _measure ( YGNodeConstRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode )
static
这是这个函数的调用关系图:

◆ YGBENCHMARKS()

YGBENCHMARKS ( { YGBENCHMARK("Stack with flex", { const YGNodeRef root=YGNodeNew();YGNodeStyleSetWidth(root, 100);YGNodeStyleSetHeight(root, 100);for(uint32_t i=0;i< 10;i++) { const YGNodeRef child=YGNodeNew();YGNodeSetMeasureFunc(child, _measure);YGNodeStyleSetFlex(child, 1);YGNodeInsertChild(root, child, 0);} YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);YGNodeFreeRecursive(root);});YGBENCHMARK("Align stretch in undefined axis", { const YGNodeRef root=YGNodeNew();for(uint32_t i=0;i< 10;i++) { const YGNodeRef child=YGNodeNew();YGNodeStyleSetHeight(child, 20);YGNodeSetMeasureFunc(child, _measure);YGNodeInsertChild(root, child, 0);} YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);YGNodeFreeRecursive(root);});YGBENCHMARK("Nested flex", { const YGNodeRef root=YGNodeNew();for(uint32_t i=0;i< 10;i++) { const YGNodeRef child=YGNodeNew();YGNodeStyleSetFlex(child, 1);YGNodeInsertChild(root, child, 0);for(uint32_t ii=0;ii< 10;ii++) { const YGNodeRef grandChild=YGNodeNew();YGNodeSetMeasureFunc(grandChild, _measure);YGNodeStyleSetFlex(grandChild, 1);YGNodeInsertChild(child, grandChild, 0);} } YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);YGNodeFreeRecursive(root);});YGBENCHMARK("Huge nested layout", { const YGNodeRef root=YGNodeNew();for(uint32_t i=0;i< 10;i++) { const YGNodeRef child=YGNodeNew();YGNodeStyleSetFlexGrow(child, 1);YGNodeStyleSetWidth(child, 10);YGNodeStyleSetHeight(child, 10);YGNodeInsertChild(root, child, 0);for(uint32_t ii=0;ii< 10;ii++) { const YGNodeRef grandChild=YGNodeNew();YGNodeStyleSetFlexDirection(grandChild, YGFlexDirectionRow);YGNodeStyleSetFlexGrow(grandChild, 1);YGNodeStyleSetWidth(grandChild, 10);YGNodeStyleSetHeight(grandChild, 10);YGNodeInsertChild(child, grandChild, 0);for(uint32_t iii=0;iii< 10;iii++) { const YGNodeRef grandGrandChild=YGNodeNew();YGNodeStyleSetFlexGrow(grandGrandChild, 1);YGNodeStyleSetWidth(grandGrandChild, 10);YGNodeStyleSetHeight(grandGrandChild, 10);YGNodeInsertChild(grandChild, grandGrandChild, 0);for(uint32_t iiii=0;iiii< 10;iiii++) { const YGNodeRef grandGrandGrandChild=YGNodeNew();YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow);YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1);YGNodeStyleSetWidth(grandGrandGrandChild, 10);YGNodeStyleSetHeight(grandGrandGrandChild, 10);YGNodeInsertChild(grandGrandChild, grandGrandGrandChild, 0);} } } } YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);YGNodeFreeRecursive(root);});} )
函数调用图: