From c1ae825d986d42bc2e75e85514ddf9af0f27b440 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 14 May 2019 17:04:10 +0300 Subject: [PATCH] Add some benchmarks. --- Telegram/SourceFiles/lottie/lottie_animation.cpp | 5 +++++ Telegram/SourceFiles/lottie/lottie_frame_renderer.cpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/Telegram/SourceFiles/lottie/lottie_animation.cpp b/Telegram/SourceFiles/lottie/lottie_animation.cpp index 42c4d4c6a..229e81dbe 100644 --- a/Telegram/SourceFiles/lottie/lottie_animation.cpp +++ b/Telegram/SourceFiles/lottie/lottie_animation.cpp @@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include +#include "logs.h" #include "rasterrenderer/lottierasterrenderer.h" namespace Lottie { @@ -49,8 +50,10 @@ Animation::Animation(const QByteArray &content) : _timer([=] { checkNextFrame(); }) { const auto weak = base::make_weak(this); crl::async([=] { + const auto now = crl::now(); auto error = QJsonParseError(); const auto document = QJsonDocument::fromJson(content, &error); + const auto parsed = crl::now(); if (error.error != QJsonParseError::NoError) { qCWarning(lcLottieQtBodymovinParser) << "Lottie Error: Parse failed with code " @@ -65,6 +68,8 @@ Animation::Animation(const QByteArray &content) parseDone(std::move(result)); }); } + const auto finish = crl::now(); + LOG(("INIT: %1 (PARSE %2)").arg(finish - now).arg(parsed - now)); }); } diff --git a/Telegram/SourceFiles/lottie/lottie_frame_renderer.cpp b/Telegram/SourceFiles/lottie/lottie_frame_renderer.cpp index c5648d09d..8d33a6591 100644 --- a/Telegram/SourceFiles/lottie/lottie_frame_renderer.cpp +++ b/Telegram/SourceFiles/lottie/lottie_frame_renderer.cpp @@ -193,6 +193,7 @@ void SharedState::renderFrame( if (!GoodStorageForFrame(image, size)) { image = CreateFrameStorage(size); } + const auto now = crl::now(); image.fill(Qt::transparent); QPainter p(&image); @@ -212,8 +213,13 @@ void SharedState::renderFrame( _scene.endFrame() - 1); _scene.updateProperties(frame); + const auto updated = crl::now(); + LottieRasterRenderer renderer(&p); _scene.render(renderer, frame); + + const auto finished = crl::now(); + LOG(("RENDERED: %1 (UPDATE %2)").arg(finished - now).arg(updated - now)); } void SharedState::init(QImage cover) {