2
* Copyright (c) 2010 Cyrille Berger <cberger@cberger.net>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
#include "KoColorSpacesBenchmark.h"
21
#include <qtest_kde.h>
22
#include <KoColorSpaceRegistry.h>
23
#include <KoColorSpace.h>
25
#define NB_PIXELS 1000000
27
void KoColorSpacesBenchmark::createRowsColumns()
29
QTest::addColumn<QString>("modelID");
30
QTest::addColumn<QString>("depthID");
31
QList<const KoColorSpace*> colorSpaces = KoColorSpaceRegistry::instance()->allColorSpaces(KoColorSpaceRegistry::AllColorSpaces, KoColorSpaceRegistry::OnlyDefaultProfile);
32
foreach(const KoColorSpace* colorSpace, colorSpaces) {
33
QTest::newRow(colorSpace->name().toLatin1().data()) << colorSpace->colorModelId().id() << colorSpace->colorDepthId().id();
37
#define START_BENCHMARK \
38
QFETCH(QString, modelID); \
39
QFETCH(QString, depthID); \
41
const KoColorSpace* colorSpace = KoColorSpaceRegistry::instance()->colorSpace(modelID, depthID, 0); \
42
int pixelSize = colorSpace->pixelSize(); \
43
quint8* data = new quint8[NB_PIXELS * pixelSize]; \
44
memset(data, 0, NB_PIXELS * pixelSize);
46
#define END_BENCHMARK \
49
void KoColorSpacesBenchmark::benchmarkAlpha_data()
54
void KoColorSpacesBenchmark::benchmarkAlpha()
58
quint8* data_it = data;
59
for (int i = 0; i < NB_PIXELS; ++i) {
60
colorSpace->opacityU8(data_it);
67
void KoColorSpacesBenchmark::benchmarkAlpha2_data()
72
void KoColorSpacesBenchmark::benchmarkAlpha2()
76
quint8* data_it = data;
77
for (int i = 0; i < NB_PIXELS; ++i) {
78
colorSpace->opacityF(data_it);
85
void KoColorSpacesBenchmark::benchmarkSetAlpha_data()
90
void KoColorSpacesBenchmark::benchmarkSetAlpha()
94
colorSpace->setOpacity(data, OPACITY_OPAQUE_U8, NB_PIXELS);
99
void KoColorSpacesBenchmark::benchmarkSetAlpha2_data()
104
void KoColorSpacesBenchmark::benchmarkSetAlpha2()
108
colorSpace->setOpacity(data, OPACITY_OPAQUE_F, NB_PIXELS);
113
void KoColorSpacesBenchmark::benchmarkSetAlphaIndividualCall_data()
118
void KoColorSpacesBenchmark::benchmarkSetAlphaIndividualCall()
122
quint8* data_it = data;
123
for (int i = 0; i < NB_PIXELS; ++i) {
124
colorSpace->setOpacity(data_it, OPACITY_OPAQUE_U8, 1);
125
data_it += pixelSize;
131
void KoColorSpacesBenchmark::benchmarkSetAlpha2IndividualCall_data()
136
void KoColorSpacesBenchmark::benchmarkSetAlpha2IndividualCall()
140
quint8* data_it = data;
141
for (int i = 0; i < NB_PIXELS; ++i) {
142
colorSpace->setOpacity(data_it, OPACITY_OPAQUE_F, 1);
143
data_it += pixelSize;
149
QTEST_KDEMAIN(KoColorSpacesBenchmark, GUI)
151
#include "KoColorSpacesBenchmark.moc"