Commit 270dc871 authored by Lukáš Tvrdý's avatar Lukáš Tvrdý

Add benchmarks for blur& contrast/brightness filters.

svn path=/trunk/koffice/; revision=1080612
parent 1418534f
......@@ -13,6 +13,8 @@ set(kis_viterator_benchmark_SRCS kis_vline_iterator_benchmark.cpp)
set(kis_rect_iterator_benchmark_SRCS kis_rect_iterator_benchmark.cpp)
set(kis_random_iterator_benchmark_SRCS kis_random_iterator_benchmark.cpp)
set(kis_projection_benchmark_SRCS kis_projection_benchmark.cpp)
set(kis_bcontrast_benchmark_SRCS kis_bcontrast_benchmark.cpp)
set(kis_blur_benchmark_SRCS kis_blur_benchmark.cpp)
kde4_add_unit_test(KisDatamanagerBenchmark TESTNAME krita-benchmarks-KisDataManager ${kis_datamanager_benchmark_SRCS})
......@@ -21,10 +23,14 @@ kde4_add_unit_test(KisVLineIteratorBenchmark TESTNAME krita-benchmarks-KisVLineI
kde4_add_unit_test(KisRectIteratorBenchmark TESTNAME krita-benchmarks-KisRectIterator ${kis_rect_iterator_benchmark_SRCS})
kde4_add_unit_test(KisRandomIteratorBenchmark TESTNAME krita-benchmarks-KisRandomIterator ${kis_random_iterator_benchmark_SRCS})
kde4_add_unit_test(KisProjectionBenchmark TESTNAME krita-benchmarks-KisProjectionBenchmark ${kis_projection_benchmark_SRCS})
kde4_add_unit_test(KisBContrastBenchmark TESTNAME krita-benchmarks-KisBContrastBenchmark ${kis_bcontrast_benchmark_SRCS})
kde4_add_unit_test(KisBlurBenchmark TESTNAME krita-benchmarks-KisBlurBenchmark ${kis_blur_benchmark_SRCS})
target_link_libraries(KisDatamanagerBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
target_link_libraries(KisHLineIteratorBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
target_link_libraries(KisVLineIteratorBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
target_link_libraries(KisRectIteratorBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
target_link_libraries(KisRandomIteratorBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
target_link_libraries(KisProjectionBenchmark ${KDE4_KDEUI_LIBS} kritaimage kritaui ${QT_QTTEST_LIBRARY})
\ No newline at end of file
target_link_libraries(KisProjectionBenchmark ${KDE4_KDEUI_LIBS} kritaimage kritaui ${QT_QTTEST_LIBRARY})
target_link_libraries(KisBContrastBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
target_link_libraries(KisBlurBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
\ No newline at end of file
/*
* Copyright (c) 2010 Lukáš Tvrdý lukast.dev@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 <qtest_kde.h>
#include "kis_bcontrast_benchmark.h"
#include "kis_benchmark_values.h"
#include "kis_paint_device.h"
#include "kis_iterators_pixel.h"
#include <KoColorSpace.h>
#include <KoColorSpaceRegistry.h>
#include <KoColor.h>
#include <kis_image.h>
#include "filter/kis_filter_registry.h"
#include "filter/kis_filter_configuration.h"
#include "filter/kis_filter.h"
#include "kis_processing_information.h"
#include "kis_selection.h"
#define GMP_IMAGE_WIDTH 3274
#define GMP_IMAGE_HEIGHT 2067
void KisBContrastBenchmark::initTestCase()
{
m_colorSpace = KoColorSpaceRegistry::instance()->rgb8();
m_device = new KisPaintDevice(m_colorSpace);
m_color = new KoColor(m_colorSpace);
QColor qcolor(Qt::red);
srand(31524744);
int r,g,b;
KisRectIterator it = m_device->createRectIterator(0,0,GMP_IMAGE_WIDTH, GMP_IMAGE_HEIGHT);
while (!it.isDone()) {
r = rand() % 255;
g = rand() % 255;
b = rand() % 255;
m_color->fromQColor(QColor(r,g,b));
memcpy(it.rawData(), m_color->data(), m_colorSpace->pixelSize());
++it;
}
}
void KisBContrastBenchmark::cleanupTestCase()
{
}
void KisBContrastBenchmark::benchmarkProjection()
{
KisFilterSP filter = KisFilterRegistry::instance()->value("brightnesscontrast");
KisFilterConfiguration * kfc = filter->defaultConfiguration(m_device);
/* // Get the predefined configuration from a file
QFile file(QString(FILES_DATA_DIR) + QDir::separator() + filter->id() + ".cfg");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
out << kfc->toXML();
} else {
QString s;
QTextStream in(&file);
s = in.readAll();
kfc->fromXML(s);
}
*/
KisConstProcessingInformation src(m_device, QPoint(0, 0), 0);
KisProcessingInformation dst(m_device, QPoint(0, 0), 0);
QBENCHMARK{
filter->process(src, dst, QSize(GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT), kfc);
}
}
QTEST_KDEMAIN(KisBContrastBenchmark, GUI)
#include "kis_bcontrast_benchmark.moc"
/*
* Copyright (c) 2010 Lukáš Tvrdý lukast.dev@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 KIS_BCONTRAST_BENCHMARK_H
#define KIS_BCONTRAST_BENCHMARK_H
#include <QtTest/QtTest>
class KisPaintDevice;
class KoColorSpace;
class KoColor;
class KisBContrastBenchmark : public QObject
{
Q_OBJECT
private:
const KoColorSpace * m_colorSpace;
KisPaintDevice * m_device;
KoColor * m_color;
private slots:
void initTestCase();
void cleanupTestCase();
void benchmarkProjection();
};
#endif
/*
* Copyright (c) 2010 Lukáš Tvrdý lukast.dev@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 <qtest_kde.h>
#include "kis_blur_benchmark.h"
#include "kis_benchmark_values.h"
#include "kis_paint_device.h"
#include "kis_iterators_pixel.h"
#include <KoColorSpace.h>
#include <KoColorSpaceRegistry.h>
#include <KoColor.h>
#include <kis_image.h>
#include "filter/kis_filter_registry.h"
#include "filter/kis_filter_configuration.h"
#include "filter/kis_filter.h"
#include "kis_processing_information.h"
#include "kis_selection.h"
// #define GMP_IMAGE_WIDTH 3274
// #define GMP_IMAGE_HEIGHT 2067
#define GMP_IMAGE_WIDTH 327
#define GMP_IMAGE_HEIGHT 206
void KisBlurBenchmark::initTestCase()
{
m_colorSpace = KoColorSpaceRegistry::instance()->rgb8();
m_device = new KisPaintDevice(m_colorSpace);
m_color = new KoColor(m_colorSpace);
QColor qcolor(Qt::red);
srand(31524744);
int r,g,b;
KisRectIterator it = m_device->createRectIterator(0,0,GMP_IMAGE_WIDTH, GMP_IMAGE_HEIGHT);
while (!it.isDone()) {
r = rand() % 255;
g = rand() % 255;
b = rand() % 255;
m_color->fromQColor(QColor(r,g,b));
memcpy(it.rawData(), m_color->data(), m_colorSpace->pixelSize());
++it;
}
qDebug() << m_device->exactBounds();
}
void KisBlurBenchmark::cleanupTestCase()
{
delete m_device;
delete m_color;
}
void KisBlurBenchmark::benchmarkProjection()
{
KisFilterSP filter = KisFilterRegistry::instance()->value("blur");
KisFilterConfiguration * kfc = filter->defaultConfiguration(m_device);
/* // Get the predefined configuration from a file
QFile file(QString(FILES_DATA_DIR) + QDir::separator() + filter->id() + ".cfg");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
out << kfc->toXML();
} else {
QString s;
QTextStream in(&file);
s = in.readAll();
kfc->fromXML(s);
}
*/
KisConstProcessingInformation src(m_device, QPoint(0, 0), 0);
KisProcessingInformation dst(m_device, QPoint(0, 0), 0);
QBENCHMARK{
filter->process(src, dst, QSize(GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT), kfc);
}
}
QTEST_KDEMAIN(KisBlurBenchmark, GUI)
#include "kis_blur_benchmark.moc"
/*
* Copyright (c) 2010 Lukáš Tvrdý lukast.dev@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 KIS_BLUR_BENCHMARK_H
#define KIS_BLUR_BENCHMARK_H
#include <QtTest/QtTest>
class KisPaintDevice;
class KoColorSpace;
class KoColor;
class KisBlurBenchmark : public QObject
{
Q_OBJECT
private:
const KoColorSpace * m_colorSpace;
KisPaintDevice * m_device;
KoColor * m_color;
private slots:
void initTestCase();
void cleanupTestCase();
void benchmarkProjection();
};
#endif
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