Commit 9d337426 authored by Lukáš Tvrdý's avatar Lukáš Tvrdý

Add read/write test to hline iterator

svn path=/trunk/koffice/; revision=1080001
parent 8a919700
......@@ -56,8 +56,9 @@ void KisHLineIteratorBenchmark::benchmarkCreation()
void KisHLineIteratorBenchmark::benchmarkWriteBytes()
{
KisHLineIteratorPixel it = m_device->createHLineIterator(0, 0, TEST_IMAGE_WIDTH);
QBENCHMARK{
KisHLineIteratorPixel it = m_device->createHLineIterator(0, 0, TEST_IMAGE_WIDTH);
for (int j = 0; j < TEST_IMAGE_HEIGHT; j++) {
while (!it.isDone()) {
memcpy(it.rawData(), m_color->data(), m_colorSpace->pixelSize());
......@@ -70,8 +71,9 @@ void KisHLineIteratorBenchmark::benchmarkWriteBytes()
void KisHLineIteratorBenchmark::benchmarkReadBytes()
{
KisHLineIteratorPixel it = m_device->createHLineIterator(0, 0, TEST_IMAGE_WIDTH);
QBENCHMARK{
KisHLineIteratorPixel it = m_device->createHLineIterator(0, 0, TEST_IMAGE_WIDTH);
for (int j = 0; j < TEST_IMAGE_HEIGHT; j++) {
while (!it.isDone()) {
memcpy(m_color->data(), it.rawData(), m_colorSpace->pixelSize());
......@@ -85,8 +87,9 @@ void KisHLineIteratorBenchmark::benchmarkReadBytes()
void KisHLineIteratorBenchmark::benchmarkConstReadBytes()
{
KisHLineConstIteratorPixel cit = m_device->createHLineConstIterator(0, 0, TEST_IMAGE_WIDTH);
QBENCHMARK{
KisHLineConstIteratorPixel cit = m_device->createHLineConstIterator(0, 0, TEST_IMAGE_WIDTH);
for (int j = 0; j < TEST_IMAGE_HEIGHT; j++) {
while (!cit.isDone()) {
memcpy(m_color->data(), cit.rawData(), m_colorSpace->pixelSize());
......@@ -97,6 +100,29 @@ void KisHLineIteratorBenchmark::benchmarkConstReadBytes()
}
}
void KisHLineIteratorBenchmark::benchmarkReadWriteBytes(){
KoColor c(m_colorSpace);
c.fromQColor(QColor(250,120,0));
KisPaintDevice dab(m_colorSpace);
dab.fill(0,0,TEST_IMAGE_WIDTH,TEST_IMAGE_HEIGHT, c.data());
KisHLineIteratorPixel writeIterator = m_device->createHLineIterator(0, 0, TEST_IMAGE_WIDTH);
KisHLineConstIteratorPixel constReadIterator = dab.createHLineConstIterator(0, 0, TEST_IMAGE_WIDTH);
QBENCHMARK{
for (int j = 0; j < TEST_IMAGE_HEIGHT; j++) {
while (!constReadIterator.isDone()) {
memcpy(writeIterator.rawData(), constReadIterator.rawData(), m_colorSpace->pixelSize());
++constReadIterator;
++writeIterator;
}
constReadIterator.nextRow();
writeIterator.nextRow();
}
}
}
QTEST_KDEMAIN(KisHLineIteratorBenchmark, GUI)
......
......@@ -16,8 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_DATAMANAGER_BENCHMARK_H
#define KIS_DATAMANAGER_BENCHMARK_H
#ifndef KIS_HLINEITERATOR_BENCHMARK_H
#define KIS_HLINEITERATOR_BENCHMARK_H
#include <QtTest/QtTest>
......@@ -47,6 +47,8 @@ private slots:
void benchmarkReadBytes();
// const hline iterator used
void benchmarkConstReadBytes();
// copy from one device to another
void benchmarkReadWriteBytes();
};
#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