このページでは

C

パフォーマンス測定用プラットフォームAPIの実装

Qul::Platform::PerformanceMetrics 構造体を継承し、最大ヒープ使用量、最大スタック使用量、およびCPU負荷に関する仮想関数をオーバーライドします。プラットフォーム向けのパフォーマンスメトリクスについて、独自の実装を作成してください:

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
};

プラットフォームのコンテキストでPlatformContext::performanceMetrics を実装し、この情報を返すことで、ExamplePerformanceMetrics 構造体がQt Quick Ultralite Coreにアクセスできるようにします。

Platform::PerformanceMetrics *ExamplePlatform::performanceMetrics(void)
{
    static ExamplePerformanceMetrics metrics;
    return &metrics;
}

メモリ統計

このプラットフォームには、ヒープやスタックのサイズなどのメモリ統計情報を取得するための関数が用意されています。

このような情報を出力するには、Qul::Platform::printHeapStats およびQul::Platform::printStackStats 関数を実装する必要があります。お使いのプラットフォームでmallinfo() 関数が利用可能な場合は、それを使用することもできます。

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);
}

特定のQtライセンスの下で利用可能です。
詳細はこちら。