Commit 4e7960ca authored by Dmitry Kazakov's avatar Dmitry Kazakov

Implement a benchmark for frames rendering

parent 14904e84
......@@ -36,6 +36,7 @@ set(kis_floodfill_benchmark_SRCS kis_floodfill_benchmark.cpp)
set(kis_gradient_benchmark_SRCS kis_gradient_benchmark.cpp)
set(kis_mask_generator_benchmark_SRCS kis_mask_generator_benchmark.cpp)
set(kis_low_memory_benchmark_SRCS kis_low_memory_benchmark.cpp)
set(KisAnimationRenderingBenchmark_SRCS KisAnimationRenderingBenchmark.cpp)
set(kis_filter_selections_benchmark_SRCS kis_filter_selections_benchmark.cpp)
if (UNIX)
#set(kis_composition_benchmark_SRCS kis_composition_benchmark.cpp)
......@@ -57,6 +58,7 @@ krita_add_benchmark(KisFloodfillBenchmark TESTNAME krita-benchmarks-KisFloodFill
krita_add_benchmark(KisGradientBenchmark TESTNAME krita-benchmarks-KisGradientFill ${kis_gradient_benchmark_SRCS})
krita_add_benchmark(KisMaskGeneratorBenchmark TESTNAME krita-benchmarks-KisMaskGenerator ${kis_mask_generator_benchmark_SRCS})
krita_add_benchmark(KisLowMemoryBenchmark TESTNAME krita-benchmarks-KisLowMemory ${kis_low_memory_benchmark_SRCS})
krita_add_benchmark(KisAnimationRenderingBenchmark TESTNAME krita-benchmarks-KisAnimationRenderingBenchmark ${KisAnimationRenderingBenchmark_SRCS})
krita_add_benchmark(KisFilterSelectionsBenchmark TESTNAME krita-image-KisFilterSelectionsBenchmark ${kis_filter_selections_benchmark_SRCS})
if(UNIX)
#krita_add_benchmark(KisCompositionBenchmark TESTNAME krita-benchmarks-KisComposition ${kis_composition_benchmark_SRCS})
......@@ -77,6 +79,7 @@ target_link_libraries(KisFastMathBenchmark kritaimage Qt5::Test)
target_link_libraries(KisFloodfillBenchmark kritaimage Qt5::Test)
target_link_libraries(KisGradientBenchmark kritaimage Qt5::Test)
target_link_libraries(KisLowMemoryBenchmark kritaimage Qt5::Test)
target_link_libraries(KisAnimationRenderingBenchmark kritaimage kritaui Qt5::Test)
target_link_libraries(KisFilterSelectionsBenchmark kritaimage Qt5::Test)
if(UNIX)
......
/*
* Copyright (c) 2017 Dmitry Kazakov <dimula73@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "KisAnimationRenderingBenchmark.h"
#include <QTest>
#include <testutil.h>
#include "kis_time_range.h"
#include "dialogs/KisAsyncAnimationFramesSaveDialog.h"
#include "kis_image_animation_interface.h"
#include "KisPart.h"
#include "KisDocument.h"
#include "kis_image.h"
#include "kis_image_config.h"
namespace {
void removeTempFiles(const QString &filesMask)
{
QFileInfo info(filesMask);
QDir dir(info.absolutePath());
QStringList filesList = dir.entryList({ info.fileName() });
if (!filesList.isEmpty()) {
Q_FOREACH (const QString &file, filesList) {
if (!dir.remove(file)) {
QFAIL("Couldn't remove the old testing file!");
}
}
}
}
void runRenderingTest(KisImageSP image, int numCores, int numClones)
{
{
KisImageConfig cfg;
cfg.setMaxNumberOfThreads(numCores);
cfg.setFrameRenderingClones(numClones);
}
const KisTimeRange range = image->animationInterface()->fullClipRange();
KisAsyncAnimationFramesSaveDialog dlg(image, range, "temp_frames.png", 0, 0);
dlg.setBatchMode(true);
// repeat rendering twice!
for (int i = 0; i < 1; i++) {
removeTempFiles(dlg.savedFilesMaskWildcard());
KisAsyncAnimationFramesSaveDialog::Result result = dlg.regenerateRange(0);
QCOMPARE(result, KisAsyncAnimationFramesSaveDialog::RenderComplete);
removeTempFiles(dlg.savedFilesMaskWildcard());
}
}
}
void KisAnimationRenderingBenchmark::testCacheRendering()
{
const QString fileName = TestUtil::fetchDataFileLazy("miloor_turntable_002.kra", true);
QVERIFY(QFileInfo(fileName).exists());
QScopedPointer<KisDocument> doc(KisPart::instance()->createDocument());
bool loadingResult = doc->loadNativeFormat(fileName);
QVERIFY(loadingResult);
doc->image()->barrierLock();
doc->image()->unlock();
for (int numCores = 1; numCores <= QThread::idealThreadCount(); numCores++) {
QElapsedTimer timer;
timer.start();
const int numClones = qMax(1, numCores / 2);
runRenderingTest(doc->image(), numCores, numClones);
qDebug() << "Cores:" << numCores << "Clones:" << numClones << "Time:" << timer.elapsed();
}
for (int numCores = 1; numCores <= QThread::idealThreadCount(); numCores++) {
QElapsedTimer timer;
timer.start();
const int numClones = numCores;
runRenderingTest(doc->image(), numCores, numClones);
qDebug() << "Cores:" << numCores << "Clones:" << numClones << "Time:" << timer.elapsed();
}
}
QTEST_MAIN(KisAnimationRenderingBenchmark)
/*
* Copyright (c) 2017 Dmitry Kazakov <dimula73@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KISANIMATIONRENDERINGBENCHMARK_H
#define KISANIMATIONRENDERINGBENCHMARK_H
#include <QtTest>
class KisAnimationRenderingBenchmark : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testCacheRendering();
};
#endif // KISANIMATIONRENDERINGBENCHMARK_H
......@@ -470,7 +470,7 @@ void KisImageConfig::setMaxNumberOfThreads(int value)
int KisImageConfig::frameRenderingClones(bool defaultValue) const
{
const int defaultClonesCount = qMax(1, QThread::idealThreadCount() / 2);
const int defaultClonesCount = qMax(1, maxNumberOfThreads(defaultValue) / 2);
return defaultValue ? defaultClonesCount : m_config.readEntry("frameRenderingClones", defaultClonesCount);
}
......
......@@ -1076,8 +1076,11 @@ bool KisDocument::openFile()
dbgUI << localFilePath() << "type:" << typeName;
KisMainWindow *window = KisPart::instance()->currentMainwindow();
KoUpdaterPtr updater = window->viewManager()->createUnthreadedUpdater(i18n("Opening document"));
d->importExportManager->setUpdater(updater);
if (window) {
KoUpdaterPtr updater = window->viewManager()->createUnthreadedUpdater(i18n("Opening document"));
d->importExportManager->setUpdater(updater);
}
KisImportExportFilter::ConversionStatus status;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment