Add some benchmarks.

This commit is contained in:
John Preston 2019-05-14 17:04:10 +03:00
parent fbc206ebee
commit c1ae825d98
2 changed files with 11 additions and 0 deletions

View File

@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QJsonDocument> #include <QJsonDocument>
#include <QFile> #include <QFile>
#include "logs.h"
#include "rasterrenderer/lottierasterrenderer.h" #include "rasterrenderer/lottierasterrenderer.h"
namespace Lottie { namespace Lottie {
@ -49,8 +50,10 @@ Animation::Animation(const QByteArray &content)
: _timer([=] { checkNextFrame(); }) { : _timer([=] { checkNextFrame(); }) {
const auto weak = base::make_weak(this); const auto weak = base::make_weak(this);
crl::async([=] { crl::async([=] {
const auto now = crl::now();
auto error = QJsonParseError(); auto error = QJsonParseError();
const auto document = QJsonDocument::fromJson(content, &error); const auto document = QJsonDocument::fromJson(content, &error);
const auto parsed = crl::now();
if (error.error != QJsonParseError::NoError) { if (error.error != QJsonParseError::NoError) {
qCWarning(lcLottieQtBodymovinParser) qCWarning(lcLottieQtBodymovinParser)
<< "Lottie Error: Parse failed with code " << "Lottie Error: Parse failed with code "
@ -65,6 +68,8 @@ Animation::Animation(const QByteArray &content)
parseDone(std::move(result)); parseDone(std::move(result));
}); });
} }
const auto finish = crl::now();
LOG(("INIT: %1 (PARSE %2)").arg(finish - now).arg(parsed - now));
}); });
} }

View File

@ -193,6 +193,7 @@ void SharedState::renderFrame(
if (!GoodStorageForFrame(image, size)) { if (!GoodStorageForFrame(image, size)) {
image = CreateFrameStorage(size); image = CreateFrameStorage(size);
} }
const auto now = crl::now();
image.fill(Qt::transparent); image.fill(Qt::transparent);
QPainter p(&image); QPainter p(&image);
@ -212,8 +213,13 @@ void SharedState::renderFrame(
_scene.endFrame() - 1); _scene.endFrame() - 1);
_scene.updateProperties(frame); _scene.updateProperties(frame);
const auto updated = crl::now();
LottieRasterRenderer renderer(&p); LottieRasterRenderer renderer(&p);
_scene.render(renderer, frame); _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) { void SharedState::init(QImage cover) {