From 899ea7769575bb973975200227c11d4cf147e6bc Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 22 Aug 2023 11:34:12 +0900 Subject: [PATCH] exmamples lottie: add a time measurement. --- src/examples/Lottie.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/examples/Lottie.cpp b/src/examples/Lottie.cpp index 65477899..e60959de 100644 --- a/src/examples/Lottie.cpp +++ b/src/examples/Lottie.cpp @@ -39,6 +39,12 @@ static std::vector> animations; static std::vector transitions; static unique_ptr swCanvas; +//performance measure +static double updateTime = 0; +static double accumUpdateTime = 0; +static double accumRasterTime = 0; +static double accumTotalTime = 0; +static uint32_t cnt = 0; void lottieDirCallback(const char* name, const char* path, void* data) { @@ -86,12 +92,18 @@ void lottieDirCallback(const char* name, const char* path, void* data) void tvgUpdateCmds(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress) { + auto before = ecore_time_get(); + auto animation = static_cast(effect); //Update animation frame animation->frame(roundf(animation->totalFrame() * progress)); swCanvas->update(animation->picture()); + + auto after = ecore_time_get(); + + updateTime += after - before; } void tvgSwTest(uint32_t* buffer) @@ -123,9 +135,25 @@ void tvgSwTest(uint32_t* buffer) void drawSwView(void* data, Eo* obj) { + auto before = ecore_time_get(); + if (swCanvas->draw() == tvg::Result::Success) { swCanvas->sync(); } + + auto after = ecore_time_get(); + + auto rasterTime = after - before; + + ++cnt; + + accumUpdateTime += updateTime; + accumRasterTime += rasterTime; + accumTotalTime += (updateTime + rasterTime); + + printf("[%5d]: update = %fs, raster = %fs, total = %fs\n", cnt, accumUpdateTime / cnt, accumRasterTime / cnt, accumTotalTime / cnt); + + updateTime = 0; } Eina_Bool animatorCb(void *data)