C
Implementing performance metrics platform APIs
Derive from the Qul::Platform::PerformanceMetrics structure and override the virtual functions for maximum heap usage, maximum stack usage, and CPU load. Create a custom implementation for the performance metrics for your platform:
struct ExamplePerformanceMetrics : PerformanceMetrics
{
uint64_t maxHeapUsage() QUL_DECL_OVERRIDE
{
/*Custom maximum heap usage function depending on Platform and toolchains.*/
return 0;
}
uint64_t maxStackUsage() QUL_DECL_OVERRIDE
{
/*Custom maximum stack usage function depending on Platform and toolchains.*/
return 0;
}
#if defined(QUL_ENABLE_HARDWARE_PERFORMANCE_LOGGING)
float cpuLoad() QUL_DECL_OVERRIDE
{
/*Custom CPU load measurement function depending on Platform and toolchains.*/
return 0.f;
};
#endif
};Implement PlatformContext::performanceMetrics in your platform context to return this information to provide the ExamplePerformanceMetrics structure access to the Qt Quick Ultralite Core.
Platform::PerformanceMetrics *ExamplePlatform::performanceMetrics(void)
{
static ExamplePerformanceMetrics metrics;
return &metrics;
}Memory statistics
The platform offers functions to get memory statistics like heap and stack sizes.
The Qul::Platform::printHeapStats and Qul::Platform::printStackStats functions must be implemented to print such information. You could use the mallinfo() function, if it is available on your platform.
void printHeapStats(void)
{
struct mallinfo mi = mallinfo();
PlatformInterface::log("Heap: %u/%u (in-use/total)\r\n", mi.uordblks, mi.arena);
}
void printStackStats(void)
{
// Replace this with actual measuring for your platform
uint32_t maxUsedStackSize = 0;
PlatformInterface::log("Stack: %u (peak)\r\n", maxUsedStackSize);
}void printHeapStats(void)
{
struct mallinfo mi = __iar_dlmallinfo();
PlatformInterface::log("Heap: %u/%u (in-use/total)\r\n", mi.uordblks, mi.arena);
}
void printStackStats(void)
{
// Replace this with actual measuring for your platform
uint32_t maxUsedStackSize = 0;
PlatformInterface::log("Stack: %u (peak)\r\n", maxUsedStackSize);
}Available under certain Qt licenses.
Find out more.