diff options
Diffstat (limited to 'krita/plugins/viewplugins/performancetest')
8 files changed, 1795 insertions, 0 deletions
diff --git a/krita/plugins/viewplugins/performancetest/Makefile.am b/krita/plugins/viewplugins/performancetest/Makefile.am new file mode 100644 index 000000000..bcbd2d186 --- /dev/null +++ b/krita/plugins/viewplugins/performancetest/Makefile.am @@ -0,0 +1,24 @@ +kritarcdir = $(kde_datadir)/kritaplugins +kritarc_DATA = perftest.rc + +EXTRA_DIST = $(kritarc_DATA) + +INCLUDES = -I$(srcdir)/../../../sdk \ + -I$(srcdir)/../../../core \ + -I$(srcdir)/../../../kritacolor/ \ + -I$(srcdir)/../../../ui \ + -I$/../../../ui \ + $(KOFFICE_INCLUDES) \ + $(all_includes) + +kde_module_LTLIBRARIES = kritaperftest.la + +kritaperftest_la_SOURCES = wdg_perftest.ui perftest.cc dlg_perftest.cc +noinst_HEADERS = wdg_perftest.h dlg_perftest.h perftest.h + +kritaperftest_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +kritaperftest_la_LIBADD = ../../../libkritacommon.la + +kde_services_DATA = kritaperftest.desktop + +kritaperftest_la_METASOURCES = AUTO diff --git a/krita/plugins/viewplugins/performancetest/dlg_perftest.cc b/krita/plugins/viewplugins/performancetest/dlg_perftest.cc new file mode 100644 index 000000000..1d9a045eb --- /dev/null +++ b/krita/plugins/viewplugins/performancetest/dlg_perftest.cc @@ -0,0 +1,110 @@ +/* + * dlg_perftest.cc - part of KimageShop^WKrayon^WKrita + * + * Copyright (c) 2004 Michael Thaler <michael.thaler@physik.tu-muenchen.de> + * + * 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 <config.h> + +#include <math.h> + +#include <iostream> + +using namespace std; + +#include <qradiobutton.h> +#include <qpushbutton.h> +#include <qcheckbox.h> +#include <qlabel.h> + +#include <klocale.h> +#include <knuminput.h> +#include <kdebug.h> + +#include "dlg_perftest.h" +#include "wdg_perftest.h" + + +DlgPerfTest::DlgPerfTest( QWidget * parent, + const char * name) + : super (parent, name, true, i18n("Performance Test"), Ok | Cancel, Ok) +{ + m_lock = false; + + m_page = new WdgPerfTest(this, "perf_test"); + Q_CHECK_PTR(m_page); + + setMainWidget(m_page); + resize(m_page->sizeHint()); + + connect(this, SIGNAL(okClicked()), + this, SLOT(okClicked())); + + connect(m_page->btnSelectAll, SIGNAL(clicked()), this, SLOT(selectAllClicked())); + connect(m_page->btnDeselectAll, SIGNAL(clicked()), this, SLOT(deselectAllClicked())); +} + +DlgPerfTest::~DlgPerfTest() +{ + delete m_page; +} + +WdgPerfTest * DlgPerfTest::page() +{ + return m_page; +} + +// SLOTS + +void DlgPerfTest::okClicked() +{ + accept(); +} + +void DlgPerfTest::setAllTestCheckBoxes(bool checked) +{ + m_page->chkBitBlt->setChecked(checked); + m_page->chkFill->setChecked(checked); + m_page->chkGradient->setChecked(checked); + m_page->chkPixel->setChecked(checked); + m_page->chkShape->setChecked(checked); + m_page->chkLayer->setChecked(checked); + m_page->chkScale->setChecked(checked); + m_page->chkRotate->setChecked(checked); + m_page->chkRender->setChecked(checked); + m_page->chkSelection->setChecked(checked); + m_page->chkColorConversion->setChecked(checked); + m_page->chkFilter->setChecked(checked); + m_page->chkReadBytes->setChecked(checked); + m_page->chkWriteBytes->setChecked(checked); + m_page->chkIterators->setChecked(checked); + m_page->chkPaintView->setChecked(checked); + m_page->chkPaintViewFPS->setChecked(checked); +} + +void DlgPerfTest::selectAllClicked() +{ + setAllTestCheckBoxes(true); +} + +void DlgPerfTest::deselectAllClicked() +{ + setAllTestCheckBoxes(false); +} + + +#include "dlg_perftest.moc" diff --git a/krita/plugins/viewplugins/performancetest/dlg_perftest.h b/krita/plugins/viewplugins/performancetest/dlg_perftest.h new file mode 100644 index 000000000..7cb4f1592 --- /dev/null +++ b/krita/plugins/viewplugins/performancetest/dlg_perftest.h @@ -0,0 +1,55 @@ +/* + * dlg_perftest.h -- part of KimageShop^WKrayon^WKrita + * + * Copyright (c) 2004 Michael Thaler <michael.thaler@physik.tu-muenchen.de> + * + * 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 DLG_PERFTEST_H_ +#define DLG_PERFTEST_H_ + +#include <kdialogbase.h> + +class WdgPerfTest; + +class DlgPerfTest: public KDialogBase { + typedef KDialogBase super; + Q_OBJECT + +public: + + DlgPerfTest(QWidget * parent = 0, + const char* name = 0); + ~DlgPerfTest(); + + WdgPerfTest * page(); + +private slots: + + void okClicked(); + void selectAllClicked(); + void deselectAllClicked(); + + void setAllTestCheckBoxes(bool checked); + +private: + + WdgPerfTest * m_page; + double m_oldAngle; + bool m_lock; + +}; + +#endif // DLG_PERFTEST_H diff --git a/krita/plugins/viewplugins/performancetest/kritaperftest.desktop b/krita/plugins/viewplugins/performancetest/kritaperftest.desktop new file mode 100644 index 000000000..44af65588 --- /dev/null +++ b/krita/plugins/viewplugins/performancetest/kritaperftest.desktop @@ -0,0 +1,41 @@ +[Desktop Entry] +Name=Performance Test +Name[bg]=Тест за производителност +Name[ca]=Prova d'execució +Name[da]=Ydelsestest +Name[de]=Leistungstest +Name[el]=Δοκιμή επίδοσης +Name[es]=Prueba de rendimiento +Name[et]=Jõudlustest +Name[fa]=آزمون کارایی +Name[fr]=Test de performances +Name[fy]=Prestaasjemjitting +Name[gl]=Probas de Rendemento +Name[he]=בדיקת ביצועים +Name[hu]=Teljesítményteszt +Name[is]=Afkastapróf +Name[it]=Prova delle prestazioni +Name[ja]=パフォーマンステスト +Name[km]=សាកល្បងការសម្ដែង +Name[lv]=Veiktspējas tests +Name[nb]=Ytelsestest +Name[nds]=Leistenprööv +Name[ne]=कार्य सम्पादन परीक्षण +Name[nl]=Prestatiemeting +Name[pl]=Test wydajności +Name[pt]=Teste de Performance +Name[pt_BR]=Teste de Desempenho +Name[ru]=Модуль производительности +Name[sk]=Test výkonnosti +Name[sl]=Preizkus zmogljivosti +Name[sr]=Проба перформанси +Name[sr@Latn]=Proba performansi +Name[sv]=Prestandatest +Name[uk]=Тест швидкодії +Name[uz]=Unumdorilkni tekshirish +Name[uz@cyrillic]=Унумдорилкни текшириш +Name[zh_TW]=效能測試 +ServiceTypes=Krita/ViewPlugin +Type=Service +X-KDE-Library=kritaperftest +X-Krita-Version=2 diff --git a/krita/plugins/viewplugins/performancetest/perftest.cc b/krita/plugins/viewplugins/performancetest/perftest.cc new file mode 100644 index 000000000..1c5ede342 --- /dev/null +++ b/krita/plugins/viewplugins/performancetest/perftest.cc @@ -0,0 +1,1198 @@ +/* + * perftest.cc -- Part of Krita + * + * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org> + * + * 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 <math.h> + +#include <stdlib.h> + +#include <qslider.h> +#include <qpoint.h> +#include <qradiobutton.h> +#include <qcheckbox.h> +#include <qlabel.h> +#include <qtextedit.h> +#include <qdatetime.h> + +#include <klocale.h> +#include <kiconloader.h> +#include <kinstance.h> +#include <kdialogbase.h> +#include <kmessagebox.h> +#include <kstandarddirs.h> +#include <ktempfile.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <knuminput.h> + +#include <qcolor.h> + +#include "kis_meta_registry.h" +#include <kis_resourceserver.h> +#include "kis_cursor.h" +#include <kis_doc.h> +#include <kis_config.h> +#include <kis_image.h> +#include <kis_layer.h> +#include <kis_global.h> +#include <kis_types.h> +#include <kis_view.h> +#include <kis_selection.h> +#include <kis_colorspace_factory_registry.h> +#include <kis_colorspace.h> +#include <kis_painter.h> +#include <kis_fill_painter.h> +#include <kis_id.h> +#include <kis_paint_device.h> +#include <kis_iterators_pixel.h> +#include "perftest.h" +#include "kis_filter_config_widget.h" +#include "kis_factory.h" + +#include "dlg_perftest.h" +#include "wdg_perftest.h" + +#define USE_CALLGRIND 0 + +#if USE_CALLGRIND +#include <valgrind/callgrind.h> +#endif + + +typedef KGenericFactory<PerfTest> PerfTestFactory; +K_EXPORT_COMPONENT_FACTORY( kritaperftest, PerfTestFactory( "krita" ) ) + +PerfTest::PerfTest(QObject *parent, const char *name, const QStringList &) + : KParts::Plugin(parent, name) +{ + if ( parent->inherits("KisView") ) + { + setInstance(PerfTestFactory::instance()); + setXMLFile(locate("data","kritaplugins/perftest.rc"), true); + + (void) new KAction(i18n("&Performance Test..."), 0, 0, this, SLOT(slotPerfTest()), actionCollection(), "perf_test"); + + m_view = (KisView*) parent; + } +} + +PerfTest::~PerfTest() +{ + m_view = 0; +} + +void PerfTest::slotPerfTest() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + DlgPerfTest * dlgPerfTest = new DlgPerfTest(m_view, "PerfTest"); + Q_CHECK_PTR(dlgPerfTest); + + dlgPerfTest->setCaption(i18n("Performance Test")); + + QString report = QString(""); + + if (dlgPerfTest->exec() == QDialog::Accepted) { + + Q_INT32 testCount = (Q_INT32)qRound(dlgPerfTest->page()->intTestCount->value()); + + if (dlgPerfTest->page()->chkBitBlt->isChecked()) { + kdDebug() << "bltTest:\n"; + QString s = bltTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkFill->isChecked()) { + kdDebug() << "Filltest\n"; + QString s= fillTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkGradient->isChecked()) { + kdDebug() << "Gradienttest\n"; + QString s = gradientTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkPixel->isChecked()) { + kdDebug() << "Pixeltest\n"; + QString s = pixelTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkShape->isChecked()) { + kdDebug() << "Shapetest\n"; + QString s = shapeTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkLayer->isChecked()) { + kdDebug() << "LayerTest\n"; + QString s = layerTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkScale->isChecked()) { + kdDebug() << "Scaletest\n"; + QString s = scaleTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkRotate->isChecked()) { + kdDebug() << "Rotatetest\n"; + QString s = rotateTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkRender->isChecked()) { + kdDebug() << "Rendertest\n"; + QString s = renderTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkSelection->isChecked()) { + kdDebug() << "Selectiontest\n"; + QString s = selectionTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkColorConversion->isChecked()) { + kdDebug() << "Colorconversiontest\n"; + QString s = colorConversionTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkFilter-> isChecked()) { + kdDebug() << "filtertest\n"; + QString s = filterTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkReadBytes->isChecked()) { + kdDebug() << "Readbytes test\n"; + QString s = readBytesTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkWriteBytes-> isChecked()) { + kdDebug() << "Writebytes test\n"; + QString s = writeBytesTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkIterators->isChecked()) { + kdDebug() << "Iterators test\n"; + QString s = iteratorTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkPaintView->isChecked()) { + kdDebug() << "paintview test\n"; + QString s = paintViewTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkPaintViewFPS->isChecked()) { + kdDebug() << "paint current view (fps) test\n"; + QString s = paintViewFPSTest(); + report = report.append(s); + kdDebug() << s << "\n"; + } + KDialogBase * d = new KDialogBase(m_view, "", true, "", KDialogBase::Ok); + Q_CHECK_PTR(d); + + d->setCaption("Performance test results"); + QTextEdit * e = new QTextEdit(d); + Q_CHECK_PTR(e); + d->setMainWidget(e); + e->setText(report); + e->setMinimumWidth(600); + e->setMinimumHeight(600); + d->exec(); + delete d; + + } + delete dlgPerfTest; +} + +QString PerfTest::bltTest(Q_UINT32 testCount) +{ + QString report = QString("* bitBlt test\n"); + + KisDoc * doc = m_view->canvasSubject()->document(); + KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); + + for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { + + kdDebug() << "Image->" << (*it).name() << "\n"; + + report = report.append( " Testing blitting on " + (*it).name() + "\n"); + + KisImageSP img = doc->newImage("blt-" + (*it).name(), 1000, 1000, + KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); + + report = report.append(doBlit(COMPOSITE_OVER, *it, OPACITY_OPAQUE, testCount, img)); + report = report.append( "\n"); + report = report.append(doBlit(COMPOSITE_OVER, *it, OPACITY_OPAQUE / 2, testCount, img)); + report = report.append( "\n"); + report = report.append(doBlit(COMPOSITE_COPY, *it, OPACITY_OPAQUE, testCount, img)); + report = report.append( "\n"); + report = report.append(doBlit(COMPOSITE_COPY, *it, OPACITY_OPAQUE / 2, testCount, img)); + report = report.append( "\n"); + } + + return report; + + +} + + +QString PerfTest::doBlit(const KisCompositeOp& op, + KisID cspace, + Q_UINT8 opacity, + Q_UINT32 testCount, + KisImageSP img) +{ + + QTime t; + QString report; + + // ------------------------------------------------------------------------------ + // Small + + KisPaintDeviceSP small = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "small blit"); + Q_CHECK_PTR(small); + + KisFillPainter pf(small.data()) ; + pf.fillRect(0, 0, 32, 32, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + pf.end(); + + t.restart(); + KisPainter p(img->activeDevice()); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.bitBlt(0, 0, op, small.data(),0,0,32, 32); + } + p.end(); + + report = report.append(QString(" %1 blits of rectangles < tilesize with opacity %2 and composite op %3: %4ms\n") + .arg(testCount) + .arg(opacity) + .arg(op.id().name()) + .arg(t.elapsed())); + + + // ------------------------------------------------------------------------------ + // Medium + KisPaintDeviceSP medium = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "medium blit"); + Q_CHECK_PTR(medium); + + pf.begin(medium.data()) ; + pf.fillRect(0, 0, 64 * 3, 64 * 3, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + pf.end(); + + t.restart(); + p.begin(img->activeDevice().data()); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.bitBlt(0, 0, op, medium.data(),0,0,96, 96); + } + p.end(); + + report = report.append(QString(" %1 blits of rectangles 3 * tilesize with opacity %2 and composite op %3: %4ms\n") + .arg(testCount) + .arg(opacity) + .arg(op.id().name()) + .arg(t.elapsed())); + + + // ------------------------------------------------------------------------------ + // Big + KisPaintDeviceSP big = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "big blit"); + Q_CHECK_PTR(big); + + pf.begin(big.data()) ; + pf.fillRect(0, 0, 800, 800, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + pf.end(); + + t.restart(); + p.begin(img->activeDevice().data()); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.bitBlt(0, 0, op, big.data(),0,0,800,800); + + } + p.end(); + report = report.append(QString(" %1 blits of rectangles 800 x 800 with opacity %2 and composite op %3: %4ms\n") + .arg(testCount) + .arg(opacity) + .arg(op.id().name()) + .arg(t.elapsed())); + + + // ------------------------------------------------------------------------------ + // Outside + + KisPaintDeviceSP outside = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "outside blit"); + Q_CHECK_PTR(outside); + pf.begin(outside.data()) ; + pf.fillRect(0, 0, 500, 500, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + pf.end(); + + t.restart(); + p.begin(img->activeDevice().data()); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.bitBlt(600, 600, op, outside.data(),0,0,500,500); + + } + p.end(); + report = report.append(QString(" %1 blits of rectangles 500 x 500 at 600,600 with opacity %2 and composite op %3: %4ms\n") + .arg(testCount) + .arg(opacity) + .arg(op.id().name()) + .arg(t.elapsed())); + + // ------------------------------------------------------------------------------ + // Small with varied source opacity + + KisPaintDeviceSP small_with_alpha = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "small blit with alpha"); + Q_CHECK_PTR(small_with_alpha); + + pf.begin(small_with_alpha.data()) ; + pf.fillRect(0, 0, 32, 32, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_TRANSPARENT); + pf.fillRect(4, 4, 24, 24, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2); + pf.fillRect(8, 8, 16, 16, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE); + pf.end(); + + t.restart(); + p.begin(img->activeDevice().data()); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.bitBlt(0, 0, op, small_with_alpha.data(), 0, 0, 32, 32); + } + p.end(); + + report = report.append(QString(" %1 blits of rectangles < tilesize with source alpha, with opacity %2 and composite op %3: %4ms\n") + .arg(testCount) + .arg(opacity) + .arg(op.id().name()) + .arg(t.elapsed())); + + return report; + +} + +QString PerfTest::fillTest(Q_UINT32 testCount) +{ + QString report = QString("* Fill test\n"); + + KisDoc * doc = m_view->canvasSubject()->document(); + KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); + + for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { + kdDebug() << "Filltest on " << (*it).name() + "\n"; + + report = report.append( " Testing blitting on " + (*it).name() + "\n"); + + KisImageSP img = doc->newImage("fill-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); + KisPaintDeviceSP l = img->activeDevice(); + + // Rect fill + KisFillPainter p(l.data()); + QTime t; + t.restart(); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.eraseRect(0, 0, 1000, 1000); + } + report = report.append(QString(" Erased 1000 x 1000 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + t.restart(); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.eraseRect(50, 50, 500, 500); + } + report = report.append(QString(" Erased 500 x 500 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + t.restart(); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.eraseRect(-50, -50, 1100, 1100); + } + report = report.append(QString(" Erased rect bigger than layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + // Opaque Rect fill + t.restart(); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.fillRect(0, 0, 1000, 1000, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + } + report = report.append(QString(" Opaque fill 1000 x 1000 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + t.restart(); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.fillRect(50, 50, 500, 500, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + } + report = report.append(QString(" Opaque fill 500 x 500 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + t.restart(); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.fillRect(-50, -50, 1100, 1100, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + } + report = report.append(QString(" Opaque fill rect bigger than layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + // Transparent rect fill + + t.restart(); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.fillRect(0, 0, 1000, 1000, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2); + } + report = report.append(QString(" Opaque fill 1000 x 1000 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + t.restart(); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.fillRect(50, 50, 500, 500, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2); + } + report = report.append(QString(" Opaque fill 500 x 500 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + t.restart(); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.fillRect(-50, -50, 1100, 1100, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2); + } + report = report.append(QString(" Opaque fill rect bigger than layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + // Colour fill + + t.restart(); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.eraseRect(0, 0, 1000, 1000); +// p.paintEllipse(500, 1000, 100, 0, 0); + p.setPaintColor(KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.setFillThreshold(15); + p.setCompositeOp(COMPOSITE_OVER); + p.fillColor(0,0); + } + report = report.append(QString(" Opaque floodfill of whole circle (incl. erase and painting of circle) %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + // Pattern fill + t.restart(); + for (Q_UINT32 i = 0; i < testCount; ++i) { + p.eraseRect(0, 0, 1000, 1000); +// p.paintEllipse(500, 1000, 100, 0, 0); + p.setPaintColor(KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + KisResourceServerBase* r = KisResourceServerRegistry::instance()->get("PatternServer"); + Q_CHECK_PTR(r); + p.setPattern((KisPattern*)r->resources().first()); + p.setFillThreshold(15); + p.setCompositeOp(COMPOSITE_OVER); + p.fillPattern(0,0); + } + report = report.append(QString(" Opaque patternfill of whole circle (incl. erase and painting of circle) %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + + } + + + + return report; + +} + +QString PerfTest::gradientTest(Q_UINT32 testCount) +{ + return QString("Gradient test\n"); +} + +QString PerfTest::pixelTest(Q_UINT32 testCount) +{ + QString report = QString("* pixel/setpixel test\n"); + + KisDoc * doc = m_view->canvasSubject()->document(); + KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); + + + for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { + report = report.append( " Testing pixel/setpixel on " + (*it).name() + "\n"); + + KisImageSP img = doc->newImage("fill-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); + + KisPaintDeviceSP l = img->activeDevice(); + + QTime t; + t.restart(); + + QColor c = Qt::black; + Q_UINT8 opacity = OPACITY_OPAQUE; + for (Q_UINT32 i = 0; i < testCount; ++i) { + for (Q_UINT32 x = 0; x < 1000; ++x) { + for (Q_UINT32 y = 0; y < 1000; ++y) { + l->pixel(x, y, &c, &opacity); + } + } + } + report = report.append(QString(" read 1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + c= Qt::black; + t.restart(); + for (Q_UINT32 i = 0; i < testCount; ++i) { + for (Q_UINT32 x = 0; x < 1000; ++x) { + for (Q_UINT32 y = 0; y < 1000; ++y) { + l->setPixel(x, y, c, 128); + } + } + } + report = report.append(QString(" written 1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + } + + + + + return report; + +} + +QString PerfTest::shapeTest(Q_UINT32 testCount) +{ + return QString("Shape test\n"); +} + +QString PerfTest::layerTest(Q_UINT32 testCount) +{ + return QString("Layer test\n"); +} + +QString PerfTest::scaleTest(Q_UINT32 testCount) +{ + return QString("Scale test\n"); +} + +QString PerfTest::rotateTest(Q_UINT32 testCount) +{ + QString report = QString("* Rotate test\n"); + + KisDoc * doc = m_view->canvasSubject()->document(); + KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); + for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { + + doc->undoAdapter()->setUndo( false ); + QTime t; + + for (uint i = 0; i < testCount; ++i) { + for (double angle = 0; angle < 360; ++angle) { + kdDebug() << "Rotating " << (*it).name() << " at " << angle << " degrees\n"; + KisImage * img = doc->newImage("cs-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); + img->rotate(angle, m_view->canvasSubject()->progressDisplay()); + kdDebug() << "Size: " << img->projection()->extent() << endl; + delete img; + } + } + report = report.append(QString(" rotated 1000 x 1000 pixels over 360 degrees, degree by degree, %1 times: %2\n").arg(testCount).arg(t.elapsed())); + } + return report; +} + +QString PerfTest::renderTest(Q_UINT32 restCount) +{ + return QString("Render test\n"); +} + +QString PerfTest::selectionTest(Q_UINT32 testCount) +{ + return QString("Selection test\n"); +} + +QString PerfTest::colorConversionTest(Q_UINT32 testCount) +{ + QString report = QString("* Colorspace conversion test\n"); + + KisDoc * doc = m_view->canvasSubject()->document(); + KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); + for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { + + KisImage * img = doc->newImage("cs-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); + + QTime t; + + KisIDList l2 = KisMetaRegistry::instance()->csRegistry()->listKeys(); + for (KisIDList::Iterator it2 = l2.begin(); it2 != l2.end(); ++it2) { + kdDebug() << "test conversion from " << (*it).name() << " to " << (*it2).name() << endl; + + t.restart(); + for (uint i = 0; i < testCount; ++i) { + KisImage * img2 = new KisImage(*img); + img2->convertTo(KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it2,"")); + delete img2; + } + report = report.append(QString(" converted from " + (*it).name() + " to " + (*it2).name() + " 1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + } + + delete img; + + } + return report; + +} + +QString PerfTest::filterTest(Q_UINT32 testCount) +{ + + QString report = QString("* Filter test\n"); + + KisIDList filters = KisFilterRegistry::instance()->listKeys(); + KisDoc * doc = m_view->canvasSubject()->document(); + KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); + + for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { + report = report.append( " Testing filtering on " + (*it).name() + "\n"); + + KisImageSP img = doc->newImage("filter-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); + KisPaintDeviceSP l = img->activeDevice(); + + QTime t; + + for (KisIDList::Iterator it = filters.begin(); it != filters.end(); ++it) { + + KisFilterSP f = KisFilterRegistry::instance()->get(*it); + t.restart(); + kdDebug() << "test filter " << f->id().name() << " on " << img->colorSpace()->id().name() << endl; + for (Q_UINT32 i = 0; i < testCount; ++i) { + f->enableProgress(); + f->process(l.data(), l.data(), f->configuration(f->createConfigurationWidget(m_view, l.data())), QRect(0, 0, 1000, 1000)); + f->disableProgress(); + } + report = report.append(QString(" filtered " + (*it).name() + "1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + } + + } + return report; + +} + +QString PerfTest::readBytesTest(Q_UINT32 testCount) +{ + QString report = QString("* Read bytes test\n\n"); + + // On default tiles + KisDoc * doc = m_view->canvasSubject()->document(); + KisImageSP img = doc->newImage("Readbytes ", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA",""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + QTime t; + t.restart(); + + for (Q_UINT32 i = 0; i < testCount; ++i) { + Q_UINT8 * newData = new Q_UINT8[1000 * 1000 * l->pixelSize()]; + Q_CHECK_PTR(newData); + l->readBytes(newData, 0, 0, 1000, 1000); + delete[] newData; + } + + report = report.append(QString(" read 1000 x 1000 pixels %1 times from empty image: %2\n").arg(testCount).arg(t.elapsed())); + + // On tiles with data + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + t.restart(); + + for (Q_UINT32 i = 0; i < testCount; ++i) { + Q_UINT8 * newData = new Q_UINT8[1000 * 1000 * l->pixelSize()]; + Q_CHECK_PTR(newData); + l->readBytes(newData, 0, 0, 1000, 1000); + delete[] newData; + } + + report = report.append(QString(" read 1000 x 1000 pixels %1 times from filled image: %2\n").arg(testCount).arg(t.elapsed())); + + return report; +} + + +QString PerfTest::writeBytesTest(Q_UINT32 testCount) +{ + QString report = QString("* Write bytes test"); + + // On default tiles + KisDoc * doc = m_view->canvasSubject()->document(); + KisImageSP img = doc->newImage("Writebytes ", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + + Q_UINT8 * data = new Q_UINT8[1000 * 1000 * l->pixelSize()]; + Q_CHECK_PTR(data); + l->readBytes(data, 0, 0, 1000, 1000); + + QTime t; + t.restart(); + for (Q_UINT32 i = 0; i < testCount; ++i) { + l->writeBytes(data, 0, 0, 1000, 1000); + } + delete[] data; + report = report.append(QString(" written 1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); + return report; + + +} + +/////// Iterator tests + + +QString hlineRODefault(KisDoc * doc, Q_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + QTime t; + t.restart(); + + + for (Q_UINT32 i = 0; i < testCount; ++i) { + int adv; + + for(Q_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, false); + while(! hiter.isDone()) + { + adv = hiter.nConseqHPixels(); + hiter += adv; + } + } + + } + + return QString(" hline iterated read-only 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); + + +} + +QString hlineRO(KisDoc * doc, Q_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + QTime t; + t.restart(); + + for (Q_UINT32 i = 0; i < testCount; ++i) { + int adv; + + for(Q_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, false); + while(! hiter.isDone()) + { + adv = hiter.nConseqHPixels(); + hiter += adv; + } + } + + } + + return QString(" hline iterated read-only 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + +QString hlineWRDefault(KisDoc * doc, Q_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + QTime t; + t.restart(); + + for (Q_UINT32 i = 0; i < testCount; ++i) { + int adv; + + for(Q_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, true); + while(! hiter.isDone()) + { + adv = hiter.nConseqHPixels(); + hiter += adv; + } + } + + } + + return QString(" hline iterated writable 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + +QString hlineWR(KisDoc * doc, Q_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + + QTime t; + t.restart(); + + for (Q_UINT32 i = 0; i < testCount; ++i) { + int adv; + for(Q_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, true); + while(! hiter.isDone()) + { + adv = hiter.nConseqHPixels(); + hiter += adv; + } + } + + } + + return QString(" hline iterated writable 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + + +QString vlineRODefault(KisDoc * doc, Q_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + QTime t; + t.restart(); + + for (Q_UINT32 i = 0; i < testCount; ++i) { + for(Q_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisVLineIterator hiter = l->createVLineIterator(y2, 0, 1000, true); + while(! hiter.isDone()) + { + ++hiter; + } + } + + } + + return QString(" vline iterated read-only 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + +QString vlineRO(KisDoc * doc, Q_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + + QTime t; + t.restart(); + + for (Q_UINT32 i = 0; i < testCount; ++i) { + for(Q_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisVLineIterator hiter = l->createVLineIterator(y2, 0, 1000, true); + while(! hiter.isDone()) + { + ++hiter; + } + } + + } + + return QString(" vline iterated read-only 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + +QString vlineWRDefault(KisDoc * doc, Q_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + QTime t; + t.restart(); + + for (Q_UINT32 i = 0; i < testCount; ++i) { + + for(Q_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisVLineIterator hiter = l->createVLineIterator(y2, 0, 1000, true); + while(! hiter.isDone()) + { + ++hiter; + } + } + + } + + return QString(" vline iterated writable 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); +} + +QString vlineWR(KisDoc * doc, Q_UINT32 testCount) +{ + + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + QTime t; + t.restart(); + + for (Q_UINT32 i = 0; i < testCount; ++i) { + for(Q_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisHLineIterator hiter = l->createHLineIterator(y2, 0, 1000, true); + while(! hiter.isDone()) + { + ++hiter; + } + } + + } + + return QString(" vline iterated writable 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + +QString rectRODefault(KisDoc * doc, Q_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); +; + QTime t; + t.restart(); + + for (Q_UINT32 i = 0; i < testCount; ++i) { + KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, false); + while(! r.isDone()) + { + ++r; + } + } + + return QString(" rect iterated read-only 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); + + +} + +QString rectRO(KisDoc * doc, Q_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + QTime t; + t.restart(); + + for (Q_UINT32 i = 0; i < testCount; ++i) { + KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, false); + while(! r.isDone()) + { + ++r; + } + } + + return QString(" rect iterated read-only 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + +QString rectWRDefault(KisDoc * doc, Q_UINT32 testCount) +{ + + + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + QTime t; + t.restart(); + + for (Q_UINT32 i = 0; i < testCount; ++i) { + KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, true); + while(! r.isDone()) + { + ++r; + } + } + + return QString(" rect iterated writable 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + +QString rectWR(KisDoc * doc, Q_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + + QTime t; + t.restart(); + + + for (Q_UINT32 i = 0; i < testCount; ++i) { + KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, true); + while(! r.isDone()) + { + ++r; + } + } + + + return QString(" rect iterated writable 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); + + +} +QString PerfTest::iteratorTest(Q_UINT32 testCount) +{ + QString report = "Iterator test"; + + KisDoc * doc = m_view->canvasSubject()->document(); + + report = report.append(hlineRODefault(doc, testCount)); + report = report.append(hlineRO(doc, testCount)); + report = report.append(hlineWRDefault(doc, testCount)); + report = report.append(hlineWR(doc, testCount)); + + report = report.append(vlineRODefault(doc, testCount)); + report = report.append(vlineRO(doc, testCount)); + report = report.append(vlineWRDefault(doc, testCount)); + report = report.append(vlineWR(doc, testCount)); + + report = report.append(rectRODefault(doc, testCount)); + report = report.append(rectRO(doc, testCount)); + report = report.append(rectWRDefault(doc, testCount)); + report = report.append(rectWR(doc, testCount)); + + return report; + + +} + +QString PerfTest::paintViewTest(Q_UINT32 testCount) +{ + QString report = QString("* paintView test\n\n"); + + KisDoc * doc = m_view->canvasSubject()->document(); + + KisImageSP img = doc->currentImage(); + img->resize(512,512); + + + KisPaintDeviceSP l = img->activeDevice(); + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 512, 512, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + QTime t; + t.restart(); + +#if USE_CALLGRIND + CALLGRIND_ZERO_STATS(); +#endif + + for (Q_UINT32 i = 0; i < testCount; ++i) { + m_view->getCanvasController()->updateCanvas(QRect(0, 0, 512, 512)); + } + +#if USE_CALLGRIND + CALLGRIND_DUMP_STATS(); +#endif + + report = report.append(QString(" painted a 512 x 512 image %1 times: %2 ms\n").arg(testCount).arg(t.elapsed())); + + img->newLayer("layer 2", OPACITY_OPAQUE); + l = img->activeDevice(); + + p.begin(l.data()); + p.fillRect(0, 0, 512, 512, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + img->newLayer("layer 3", OPACITY_OPAQUE); + l = img->activeDevice(); + + p.begin(l.data()); + p.fillRect(0, 0, 512, 512, KisColor(Qt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + t.restart(); + + for (Q_UINT32 i = 0; i < testCount; ++i) { + m_view->getCanvasController()->updateCanvas(QRect(0, 0, 512, 512)); + } + + report = report.append(QString(" painted a 512 x 512 image with 3 layers %1 times: %2 ms\n").arg(testCount).arg(t.elapsed())); + + return report; +} + +QString PerfTest::paintViewFPSTest() +{ + QString report = QString("* paintView (fps) test\n\n"); + + QTime t; + t.restart(); + +#if USE_CALLGRIND + CALLGRIND_ZERO_STATS(); +#endif + + int numViewsPainted = 0; + const int millisecondsPerSecond = 1000; + + while (t.elapsed() < millisecondsPerSecond) { + m_view->getCanvasController()->updateCanvas(); + numViewsPainted++; + } + +#if USE_CALLGRIND + CALLGRIND_DUMP_STATS(); +#endif + + report = report.append(QString(" painted current view at %1 frames per second\n").arg(numViewsPainted)); + + return report; +} + +#include "perftest.moc" diff --git a/krita/plugins/viewplugins/performancetest/perftest.h b/krita/plugins/viewplugins/performancetest/perftest.h new file mode 100644 index 000000000..6a3365c5a --- /dev/null +++ b/krita/plugins/viewplugins/performancetest/perftest.h @@ -0,0 +1,75 @@ +/* + * perftest.h -- Part of Krita + * + * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org> + * + * 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 PERFTEST_H_ +#define PERFTEST_H_ + +#include <kparts/plugin.h> +#include <kis_types.h> +#include <kis_global.h> + +class KisView; +class KisID; + +class PerfTest : public KParts::Plugin +{ + Q_OBJECT +public: + PerfTest(QObject *parent, const char *name, const QStringList &); + virtual ~PerfTest(); + +private slots: + + void slotPerfTest(); + +private: + + QString bltTest(Q_UINT32 testCount); + QString fillTest(Q_UINT32 testCount); + QString gradientTest(Q_UINT32 testCount); + QString pixelTest(Q_UINT32 testCount); + QString shapeTest(Q_UINT32 testCount); + QString layerTest(Q_UINT32 testCount); + QString scaleTest(Q_UINT32 testCount); + QString rotateTest(Q_UINT32 testCount); + QString renderTest(Q_UINT32 restCount); + QString selectionTest(Q_UINT32 testCount); + QString colorConversionTest(Q_UINT32 testCount); + QString filterTest(Q_UINT32 testCount); + QString readBytesTest(Q_UINT32 testCount); + QString writeBytesTest(Q_UINT32 testCount); + QString iteratorTest(Q_UINT32 testCount); + QString paintViewTest(Q_UINT32 testCount); + QString paintViewFPSTest(); + + QString doBlit(const KisCompositeOp& op, + KisID cspace, + Q_UINT8 opacity, + Q_UINT32 testCount, + KisImageSP img); + +private: + + KisView * m_view; + KisPainter * m_painter; + +}; + +#endif // PERFTEST_H_ diff --git a/krita/plugins/viewplugins/performancetest/perftest.rc b/krita/plugins/viewplugins/performancetest/perftest.rc new file mode 100644 index 000000000..6010e8f3f --- /dev/null +++ b/krita/plugins/viewplugins/performancetest/perftest.rc @@ -0,0 +1,9 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui library="kritaperftest" version="1"> +<MenuBar> + <Menu name="Tools"><text>&Tools</text> + <Separator/> + <Action name="perf_test"/> + </Menu> +</MenuBar> +</kpartgui>
\ No newline at end of file diff --git a/krita/plugins/viewplugins/performancetest/wdg_perftest.ui b/krita/plugins/viewplugins/performancetest/wdg_perftest.ui new file mode 100644 index 000000000..4f9ca4a09 --- /dev/null +++ b/krita/plugins/viewplugins/performancetest/wdg_perftest.ui @@ -0,0 +1,283 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>WdgPerfTest</class> +<widget class="QWidget"> + <property name="name"> + <cstring>WdgPerfTest</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>377</width> + <height>566</height> + </rect> + </property> + <property name="caption"> + <string>Image Size</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QButtonGroup" row="0" column="0"> + <property name="name"> + <cstring>grpPerfTest</cstring> + </property> + <property name="title"> + <string>&Performance Test</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>lblTests</cstring> + </property> + <property name="text"> + <string>Number of tests:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>intWidth</cstring> + </property> + </widget> + <widget class="QCheckBox" row="1" column="0"> + <property name="name"> + <cstring>chkBitBlt</cstring> + </property> + <property name="text"> + <string>bitBlt</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="2" column="0"> + <property name="name"> + <cstring>chkFill</cstring> + </property> + <property name="text"> + <string>Fill</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="3" column="0"> + <property name="name"> + <cstring>chkGradient</cstring> + </property> + <property name="text"> + <string>Gradients</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="4" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>chkPixel</cstring> + </property> + <property name="text"> + <string>setPixel/getPixel</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="5" column="0"> + <property name="name"> + <cstring>chkShape</cstring> + </property> + <property name="text"> + <string>Shapes</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="6" column="0"> + <property name="name"> + <cstring>chkLayer</cstring> + </property> + <property name="text"> + <string>Layers</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="7" column="0"> + <property name="name"> + <cstring>chkScale</cstring> + </property> + <property name="text"> + <string>Scaling</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="8" column="0"> + <property name="name"> + <cstring>chkRotate</cstring> + </property> + <property name="text"> + <string>Rotating</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="9" column="0"> + <property name="name"> + <cstring>chkRender</cstring> + </property> + <property name="text"> + <string>Rendering</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="10" column="0"> + <property name="name"> + <cstring>chkSelection</cstring> + </property> + <property name="text"> + <string>Selection</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="11" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>chkColorConversion</cstring> + </property> + <property name="text"> + <string>Color conversion</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="12" column="0"> + <property name="name"> + <cstring>chkFilter</cstring> + </property> + <property name="text"> + <string>Filters</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="KIntNumInput" row="0" column="1"> + <property name="name"> + <cstring>intTestCount</cstring> + </property> + <property name="value"> + <number>10</number> + </property> + <property name="minValue"> + <number>0</number> + </property> + <property name="maxValue"> + <number>1000000</number> + </property> + </widget> + <widget class="QCheckBox" row="13" column="0"> + <property name="name"> + <cstring>chkReadBytes</cstring> + </property> + <property name="text"> + <string>Read bytes</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="14" column="0"> + <property name="name"> + <cstring>chkWriteBytes</cstring> + </property> + <property name="text"> + <string>Write bytes</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="15" column="0"> + <property name="name"> + <cstring>chkIterators</cstring> + </property> + <property name="text"> + <string>Iterators</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="16" column="0"> + <property name="name"> + <cstring>chkPaintView</cstring> + </property> + <property name="text"> + <string>PaintView</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QLayoutWidget" row="18" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>layout5</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>btnSelectAll</cstring> + </property> + <property name="text"> + <string>&Select All</string> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>btnDeselectAll</cstring> + </property> + <property name="text"> + <string>&Deselect All</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QCheckBox" row="17" column="0"> + <property name="name"> + <cstring>chkPaintViewFPS</cstring> + </property> + <property name="text"> + <string>PaintView (fps)</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </grid> + </widget> + </grid> +</widget> +<tabstops> + <tabstop>intTestCount</tabstop> +</tabstops> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> +</includehints> +</UI> |
