summaryrefslogtreecommitdiffstats
path: root/chalk/plugins/viewplugins/performancetest
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-26 00:41:16 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-26 00:41:16 +0000
commit698569f8428ca088f764d704034a1330517b98c0 (patch)
treebf45be6946ebbbee9cce5a5bcf838f4c952d87e6 /chalk/plugins/viewplugins/performancetest
parent2785103a6bd4de55bd26d79e34d0fdd4b329a73a (diff)
downloadkoffice-698569f8428ca088f764d704034a1330517b98c0.tar.gz
koffice-698569f8428ca088f764d704034a1330517b98c0.zip
Finish rebranding of Krita as Chalk
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238363 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'chalk/plugins/viewplugins/performancetest')
-rw-r--r--chalk/plugins/viewplugins/performancetest/Makefile.am25
-rw-r--r--chalk/plugins/viewplugins/performancetest/chalkperftest.desktop41
-rw-r--r--chalk/plugins/viewplugins/performancetest/dlg_perftest.cc110
-rw-r--r--chalk/plugins/viewplugins/performancetest/dlg_perftest.h56
-rw-r--r--chalk/plugins/viewplugins/performancetest/perftest.cc1198
-rw-r--r--chalk/plugins/viewplugins/performancetest/perftest.h76
-rw-r--r--chalk/plugins/viewplugins/performancetest/perftest.rc9
-rw-r--r--chalk/plugins/viewplugins/performancetest/wdg_perftest.ui283
8 files changed, 1798 insertions, 0 deletions
diff --git a/chalk/plugins/viewplugins/performancetest/Makefile.am b/chalk/plugins/viewplugins/performancetest/Makefile.am
new file mode 100644
index 00000000..e2d7dfac
--- /dev/null
+++ b/chalk/plugins/viewplugins/performancetest/Makefile.am
@@ -0,0 +1,25 @@
+chalkrcdir = $(kde_datadir)/chalkplugins
+chalkrc_DATA = perftest.rc
+
+EXTRA_DIST = $(chalkrc_DATA)
+
+INCLUDES = -I$(srcdir)/../../../sdk \
+ -I$(srcdir)/../../../core \
+ -I$(srcdir)/../../../chalkcolor/ \
+ -I$(srcdir)/../../../ui \
+ -I$/../../../ui \
+ $(KOFFICE_INCLUDES) \
+ $(all_includes)
+
+kde_module_LTLIBRARIES = chalkperftest.la
+
+chalkperftest_la_SOURCES = wdg_perftest.ui perftest.cc dlg_perftest.cc
+noinst_HEADERS = wdg_perftest.h dlg_perftest.h perftest.h
+
+chalkperftest_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) chalkblurfilter_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT) -lkdecore -lkdeui -lkjs -lkdefx -lkio -lkparts -L../../../../chalk/chalkcolor/.libs -lchalkcolor -L../../../../chalk/core/.libs -lchalkimage \
+ -L../../../../chalk/ui/.libs -lchalkui -L../../../../lib/kofficeui/.libs -lkofficeui
+chalkperftest_la_LIBADD = ../../../libchalkcommon.la
+
+kde_services_DATA = chalkperftest.desktop
+
+chalkperftest_la_METASOURCES = AUTO
diff --git a/chalk/plugins/viewplugins/performancetest/chalkperftest.desktop b/chalk/plugins/viewplugins/performancetest/chalkperftest.desktop
new file mode 100644
index 00000000..74aee7ed
--- /dev/null
+++ b/chalk/plugins/viewplugins/performancetest/chalkperftest.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=Chalk/ViewPlugin
+Type=Service
+X-KDE-Library=chalkperftest
+X-Chalk-Version=2
diff --git a/chalk/plugins/viewplugins/performancetest/dlg_perftest.cc b/chalk/plugins/viewplugins/performancetest/dlg_perftest.cc
new file mode 100644
index 00000000..12e3f42c
--- /dev/null
+++ b/chalk/plugins/viewplugins/performancetest/dlg_perftest.cc
@@ -0,0 +1,110 @@
+/*
+ * dlg_perftest.cc - part of KimageShop^WKrayon^WChalk
+ *
+ * Copyright (c) 2004 Michael Thaler <[email protected]>
+ *
+ * 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 <tqradiobutton.h>
+#include <tqpushbutton.h>
+#include <tqcheckbox.h>
+#include <tqlabel.h>
+
+#include <klocale.h>
+#include <knuminput.h>
+#include <kdebug.h>
+
+#include "dlg_perftest.h"
+#include "wdg_perftest.h"
+
+
+DlgPerfTest::DlgPerfTest( TQWidget * tqparent,
+ const char * name)
+ : super (tqparent, 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->tqsizeHint());
+
+ connect(this, TQT_SIGNAL(okClicked()),
+ this, TQT_SLOT(okClicked()));
+
+ connect(m_page->btnSelectAll, TQT_SIGNAL(clicked()), this, TQT_SLOT(selectAllClicked()));
+ connect(m_page->btnDeselectAll, TQT_SIGNAL(clicked()), this, TQT_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/chalk/plugins/viewplugins/performancetest/dlg_perftest.h b/chalk/plugins/viewplugins/performancetest/dlg_perftest.h
new file mode 100644
index 00000000..aae398fa
--- /dev/null
+++ b/chalk/plugins/viewplugins/performancetest/dlg_perftest.h
@@ -0,0 +1,56 @@
+/*
+ * dlg_perftest.h -- part of KimageShop^WKrayon^WChalk
+ *
+ * Copyright (c) 2004 Michael Thaler <[email protected]>
+ *
+ * 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
+ TQ_OBJECT
+
+public:
+
+ DlgPerfTest(TQWidget * tqparent = 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/chalk/plugins/viewplugins/performancetest/perftest.cc b/chalk/plugins/viewplugins/performancetest/perftest.cc
new file mode 100644
index 00000000..88a50e85
--- /dev/null
+++ b/chalk/plugins/viewplugins/performancetest/perftest.cc
@@ -0,0 +1,1198 @@
+/*
+ * perftest.cc -- Part of Chalk
+ *
+ * Copyright (c) 2004 Boudewijn Rempt <[email protected]>
+ *
+ * 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 <tqslider.h>
+#include <tqpoint.h>
+#include <tqradiobutton.h>
+#include <tqcheckbox.h>
+#include <tqlabel.h>
+#include <tqtextedit.h>
+#include <tqdatetime.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 <tqcolor.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( chalkperftest, PerfTestFactory( "chalk" ) )
+
+PerfTest::PerfTest(TQObject *tqparent, const char *name, const TQStringList &)
+ : KParts::Plugin(tqparent, name)
+{
+ if ( tqparent->inherits("KisView") )
+ {
+ setInstance(PerfTestFactory::instance());
+ setXMLFile(locate("data","chalkplugins/perftest.rc"), true);
+
+ (void) new KAction(i18n("&Performance Test..."), 0, 0, this, TQT_SLOT(slotPerfTest()), actionCollection(), "perf_test");
+
+ m_view = (KisView*) tqparent;
+ }
+}
+
+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"));
+
+ TQString report = TQString("");
+
+ if (dlgPerfTest->exec() == TQDialog::Accepted) {
+
+ TQ_INT32 testCount = (TQ_INT32)tqRound(dlgPerfTest->page()->intTestCount->value());
+
+ if (dlgPerfTest->page()->chkBitBlt->isChecked()) {
+ kdDebug() << "bltTest:\n";
+ TQString s = bltTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkFill->isChecked()) {
+ kdDebug() << "Filltest\n";
+ TQString s= fillTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkGradient->isChecked()) {
+ kdDebug() << "Gradienttest\n";
+ TQString s = gradientTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkPixel->isChecked()) {
+ kdDebug() << "Pixeltest\n";
+ TQString s = pixelTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkShape->isChecked()) {
+ kdDebug() << "Shapetest\n";
+ TQString s = tqshapeTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkLayer->isChecked()) {
+ kdDebug() << "LayerTest\n";
+ TQString s = layerTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkScale->isChecked()) {
+ kdDebug() << "Scaletest\n";
+ TQString s = scaleTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkRotate->isChecked()) {
+ kdDebug() << "Rotatetest\n";
+ TQString s = rotateTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkRender->isChecked()) {
+ kdDebug() << "Rendertest\n";
+ TQString s = renderTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkSelection->isChecked()) {
+ kdDebug() << "Selectiontest\n";
+ TQString s = selectionTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkColorConversion->isChecked()) {
+ kdDebug() << "Colorconversiontest\n";
+ TQString s = colorConversionTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkFilter-> isChecked()) {
+ kdDebug() << "filtertest\n";
+ TQString s = filterTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkReadBytes->isChecked()) {
+ kdDebug() << "Readbytes test\n";
+ TQString s = readBytesTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkWriteBytes-> isChecked()) {
+ kdDebug() << "Writebytes test\n";
+ TQString s = writeBytesTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkIterators->isChecked()) {
+ kdDebug() << "Iterators test\n";
+ TQString s = iteratorTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkPaintView->isChecked()) {
+ kdDebug() << "paintview test\n";
+ TQString s = paintViewTest(testCount);
+ report = report.append(s);
+ kdDebug() << s << "\n";
+ }
+ if (dlgPerfTest->page()->chkPaintViewFPS->isChecked()) {
+ kdDebug() << "paint current view (fps) test\n";
+ TQString 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");
+ TQTextEdit * e = new TQTextEdit(d);
+ Q_CHECK_PTR(e);
+ d->setMainWidget(e);
+ e->setText(report);
+ e->setMinimumWidth(600);
+ e->setMinimumHeight(600);
+ d->exec();
+ delete d;
+
+ }
+ delete dlgPerfTest;
+}
+
+TQString PerfTest::bltTest(TQ_UINT32 testCount)
+{
+ TQString report = TQString("* 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;
+
+
+}
+
+
+TQString PerfTest::doBlit(const KisCompositeOp& op,
+ KisID cspace,
+ TQ_UINT8 opacity,
+ TQ_UINT32 testCount,
+ KisImageSP img)
+{
+
+ TQTime t;
+ TQString 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(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ pf.end();
+
+ t.restart();
+ KisPainter p(img->activeDevice());
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.bitBlt(0, 0, op, small.data(),0,0,32, 32);
+ }
+ p.end();
+
+ report = report.append(TQString(" %1 blits of rectangles < tilesize with opacity %2 and composite op %3: %4ms\n")
+ .tqarg(testCount)
+ .tqarg(opacity)
+ .tqarg(op.id().name())
+ .tqarg(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(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ pf.end();
+
+ t.restart();
+ p.begin(img->activeDevice().data());
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.bitBlt(0, 0, op, medium.data(),0,0,96, 96);
+ }
+ p.end();
+
+ report = report.append(TQString(" %1 blits of rectangles 3 * tilesize with opacity %2 and composite op %3: %4ms\n")
+ .tqarg(testCount)
+ .tqarg(opacity)
+ .tqarg(op.id().name())
+ .tqarg(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(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ pf.end();
+
+ t.restart();
+ p.begin(img->activeDevice().data());
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.bitBlt(0, 0, op, big.data(),0,0,800,800);
+
+ }
+ p.end();
+ report = report.append(TQString(" %1 blits of rectangles 800 x 800 with opacity %2 and composite op %3: %4ms\n")
+ .tqarg(testCount)
+ .tqarg(opacity)
+ .tqarg(op.id().name())
+ .tqarg(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(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ pf.end();
+
+ t.restart();
+ p.begin(img->activeDevice().data());
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.bitBlt(600, 600, op, outside.data(),0,0,500,500);
+
+ }
+ p.end();
+ report = report.append(TQString(" %1 blits of rectangles 500 x 500 at 600,600 with opacity %2 and composite op %3: %4ms\n")
+ .tqarg(testCount)
+ .tqarg(opacity)
+ .tqarg(op.id().name())
+ .tqarg(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(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_TRANSPARENT);
+ pf.fillRect(4, 4, 24, 24, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2);
+ pf.fillRect(8, 8, 16, 16, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE);
+ pf.end();
+
+ t.restart();
+ p.begin(img->activeDevice().data());
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.bitBlt(0, 0, op, small_with_alpha.data(), 0, 0, 32, 32);
+ }
+ p.end();
+
+ report = report.append(TQString(" %1 blits of rectangles < tilesize with source alpha, with opacity %2 and composite op %3: %4ms\n")
+ .tqarg(testCount)
+ .tqarg(opacity)
+ .tqarg(op.id().name())
+ .tqarg(t.elapsed()));
+
+ return report;
+
+}
+
+TQString PerfTest::fillTest(TQ_UINT32 testCount)
+{
+ TQString report = TQString("* 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());
+ TQTime t;
+ t.restart();
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.eraseRect(0, 0, 1000, 1000);
+ }
+ report = report.append(TQString(" Erased 1000 x 1000 layer %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+
+ t.restart();
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.eraseRect(50, 50, 500, 500);
+ }
+ report = report.append(TQString(" Erased 500 x 500 layer %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+
+ t.restart();
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.eraseRect(-50, -50, 1100, 1100);
+ }
+ report = report.append(TQString(" Erased rect bigger than layer %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+
+ // Opaque Rect fill
+ t.restart();
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ }
+ report = report.append(TQString(" Opaque fill 1000 x 1000 layer %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+
+ t.restart();
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.fillRect(50, 50, 500, 500, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ }
+ report = report.append(TQString(" Opaque fill 500 x 500 layer %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+
+ t.restart();
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.fillRect(-50, -50, 1100, 1100, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ }
+ report = report.append(TQString(" Opaque fill rect bigger than layer %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+ // Transparent rect fill
+
+ t.restart();
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2);
+ }
+ report = report.append(TQString(" Opaque fill 1000 x 1000 layer %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+
+ t.restart();
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.fillRect(50, 50, 500, 500, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2);
+ }
+ report = report.append(TQString(" Opaque fill 500 x 500 layer %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+
+ t.restart();
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.fillRect(-50, -50, 1100, 1100, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2);
+ }
+ report = report.append(TQString(" Opaque fill rect bigger than layer %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+ // Colour fill
+
+ t.restart();
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.eraseRect(0, 0, 1000, 1000);
+// p.paintEllipse(500, 1000, 100, 0, 0);
+ p.setPaintColor(KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ p.setFillThreshold(15);
+ p.setCompositeOp(COMPOSITE_OVER);
+ p.fillColor(0,0);
+ }
+ report = report.append(TQString(" Opaque floodfill of whole circle (incl. erase and painting of circle) %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+
+ // Pattern fill
+ t.restart();
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ p.eraseRect(0, 0, 1000, 1000);
+// p.paintEllipse(500, 1000, 100, 0, 0);
+ p.setPaintColor(KisColor(TQt::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(TQString(" Opaque patternfill of whole circle (incl. erase and painting of circle) %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+
+
+ }
+
+
+
+ return report;
+
+}
+
+TQString PerfTest::gradientTest(TQ_UINT32 testCount)
+{
+ return TQString("Gradient test\n");
+}
+
+TQString PerfTest::pixelTest(TQ_UINT32 testCount)
+{
+ TQString report = TQString("* 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();
+
+ TQTime t;
+ t.restart();
+
+ TQColor c = TQt::black;
+ TQ_UINT8 opacity = OPACITY_OPAQUE;
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ for (TQ_UINT32 x = 0; x < 1000; ++x) {
+ for (TQ_UINT32 y = 0; y < 1000; ++y) {
+ l->pixel(x, y, &c, &opacity);
+ }
+ }
+ }
+ report = report.append(TQString(" read 1000 x 1000 pixels %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+ c= TQt::black;
+ t.restart();
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ for (TQ_UINT32 x = 0; x < 1000; ++x) {
+ for (TQ_UINT32 y = 0; y < 1000; ++y) {
+ l->setPixel(x, y, c, 128);
+ }
+ }
+ }
+ report = report.append(TQString(" written 1000 x 1000 pixels %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+ }
+
+
+
+
+ return report;
+
+}
+
+TQString PerfTest::tqshapeTest(TQ_UINT32 testCount)
+{
+ return TQString("Shape test\n");
+}
+
+TQString PerfTest::layerTest(TQ_UINT32 testCount)
+{
+ return TQString("Layer test\n");
+}
+
+TQString PerfTest::scaleTest(TQ_UINT32 testCount)
+{
+ return TQString("Scale test\n");
+}
+
+TQString PerfTest::rotateTest(TQ_UINT32 testCount)
+{
+ TQString report = TQString("* 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 );
+ TQTime 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(TQString(" rotated 1000 x 1000 pixels over 360 degrees, degree by degree, %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+ }
+ return report;
+}
+
+TQString PerfTest::renderTest(TQ_UINT32 restCount)
+{
+ return TQString("Render test\n");
+}
+
+TQString PerfTest::selectionTest(TQ_UINT32 testCount)
+{
+ return TQString("Selection test\n");
+}
+
+TQString PerfTest::colorConversionTest(TQ_UINT32 testCount)
+{
+ TQString report = TQString("* 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,""));
+
+ TQTime 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(TQString(" converted from " + (*it).name() + " to " + (*it2).name() + " 1000 x 1000 pixels %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+ }
+
+ delete img;
+
+ }
+ return report;
+
+}
+
+TQString PerfTest::filterTest(TQ_UINT32 testCount)
+{
+
+ TQString report = TQString("* 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();
+
+ TQTime 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 (TQ_UINT32 i = 0; i < testCount; ++i) {
+ f->enableProgress();
+ f->process(l.data(), l.data(), f->configuration(f->createConfigurationWidget(m_view, l.data())), TQRect(0, 0, 1000, 1000));
+ f->disableProgress();
+ }
+ report = report.append(TQString(" filtered " + (*it).name() + "1000 x 1000 pixels %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+ }
+
+ }
+ return report;
+
+}
+
+TQString PerfTest::readBytesTest(TQ_UINT32 testCount)
+{
+ TQString report = TQString("* 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();
+
+ TQTime t;
+ t.restart();
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ TQ_UINT8 * newData = new TQ_UINT8[1000 * 1000 * l->pixelSize()];
+ Q_CHECK_PTR(newData);
+ l->readBytes(newData, 0, 0, 1000, 1000);
+ delete[] newData;
+ }
+
+ report = report.append(TQString(" read 1000 x 1000 pixels %1 times from empty image: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+ // On tiles with data
+
+ KisFillPainter p(l.data());
+ p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ p.end();
+
+ t.restart();
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ TQ_UINT8 * newData = new TQ_UINT8[1000 * 1000 * l->pixelSize()];
+ Q_CHECK_PTR(newData);
+ l->readBytes(newData, 0, 0, 1000, 1000);
+ delete[] newData;
+ }
+
+ report = report.append(TQString(" read 1000 x 1000 pixels %1 times from filled image: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+
+ return report;
+}
+
+
+TQString PerfTest::writeBytesTest(TQ_UINT32 testCount)
+{
+ TQString report = TQString("* 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(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ p.end();
+
+
+ TQ_UINT8 * data = new TQ_UINT8[1000 * 1000 * l->pixelSize()];
+ Q_CHECK_PTR(data);
+ l->readBytes(data, 0, 0, 1000, 1000);
+
+ TQTime t;
+ t.restart();
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ l->writeBytes(data, 0, 0, 1000, 1000);
+ }
+ delete[] data;
+ report = report.append(TQString(" written 1000 x 1000 pixels %1 times: %2\n").tqarg(testCount).tqarg(t.elapsed()));
+ return report;
+
+
+}
+
+/////// Iterator tests
+
+
+TQString hlineRODefault(KisDoc * doc, TQ_UINT32 testCount)
+{
+ KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),""));
+ KisPaintDeviceSP l = img->activeDevice();
+
+ TQTime t;
+ t.restart();
+
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ int adv;
+
+ for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++)
+ {
+ KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, false);
+ while(! hiter.isDone())
+ {
+ adv = hiter.nConseqHPixels();
+ hiter += adv;
+ }
+ }
+
+ }
+
+ return TQString(" hline iterated read-only 1000 x 1000 pixels %1 times over default tile: %2\n").tqarg(testCount).tqarg(t.elapsed());
+
+
+}
+
+TQString hlineRO(KisDoc * doc, TQ_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(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ p.end();
+
+ TQTime t;
+ t.restart();
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ int adv;
+
+ for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++)
+ {
+ KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, false);
+ while(! hiter.isDone())
+ {
+ adv = hiter.nConseqHPixels();
+ hiter += adv;
+ }
+ }
+
+ }
+
+ return TQString(" hline iterated read-only 1000 x 1000 pixels %1 times over existing tile: %2\n").tqarg(testCount).tqarg(t.elapsed());
+
+}
+
+TQString hlineWRDefault(KisDoc * doc, TQ_UINT32 testCount)
+{
+ KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),""));
+ KisPaintDeviceSP l = img->activeDevice();
+
+ TQTime t;
+ t.restart();
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ int adv;
+
+ for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++)
+ {
+ KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, true);
+ while(! hiter.isDone())
+ {
+ adv = hiter.nConseqHPixels();
+ hiter += adv;
+ }
+ }
+
+ }
+
+ return TQString(" hline iterated writable 1000 x 1000 pixels %1 times over default tile: %2\n").tqarg(testCount).tqarg(t.elapsed());
+
+}
+
+TQString hlineWR(KisDoc * doc, TQ_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(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ p.end();
+
+
+ TQTime t;
+ t.restart();
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ int adv;
+ for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++)
+ {
+ KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, true);
+ while(! hiter.isDone())
+ {
+ adv = hiter.nConseqHPixels();
+ hiter += adv;
+ }
+ }
+
+ }
+
+ return TQString(" hline iterated writable 1000 x 1000 pixels %1 times over existing tile: %2\n").tqarg(testCount).tqarg(t.elapsed());
+
+}
+
+
+TQString vlineRODefault(KisDoc * doc, TQ_UINT32 testCount)
+{
+ KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),""));
+ KisPaintDeviceSP l = img->activeDevice();
+
+ TQTime t;
+ t.restart();
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++)
+ {
+ KisVLineIterator hiter = l->createVLineIterator(y2, 0, 1000, true);
+ while(! hiter.isDone())
+ {
+ ++hiter;
+ }
+ }
+
+ }
+
+ return TQString(" vline iterated read-only 1000 x 1000 pixels %1 times over default tile: %2\n").tqarg(testCount).tqarg(t.elapsed());
+
+}
+
+TQString vlineRO(KisDoc * doc, TQ_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(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ p.end();
+
+
+ TQTime t;
+ t.restart();
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++)
+ {
+ KisVLineIterator hiter = l->createVLineIterator(y2, 0, 1000, true);
+ while(! hiter.isDone())
+ {
+ ++hiter;
+ }
+ }
+
+ }
+
+ return TQString(" vline iterated read-only 1000 x 1000 pixels %1 times over existing tile: %2\n").tqarg(testCount).tqarg(t.elapsed());
+
+}
+
+TQString vlineWRDefault(KisDoc * doc, TQ_UINT32 testCount)
+{
+ KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),""));
+ KisPaintDeviceSP l = img->activeDevice();
+
+ TQTime t;
+ t.restart();
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+
+ for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++)
+ {
+ KisVLineIterator hiter = l->createVLineIterator(y2, 0, 1000, true);
+ while(! hiter.isDone())
+ {
+ ++hiter;
+ }
+ }
+
+ }
+
+ return TQString(" vline iterated writable 1000 x 1000 pixels %1 times over default tile: %2\n").tqarg(testCount).tqarg(t.elapsed());
+}
+
+TQString vlineWR(KisDoc * doc, TQ_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(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ p.end();
+
+ TQTime t;
+ t.restart();
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++)
+ {
+ KisHLineIterator hiter = l->createHLineIterator(y2, 0, 1000, true);
+ while(! hiter.isDone())
+ {
+ ++hiter;
+ }
+ }
+
+ }
+
+ return TQString(" vline iterated writable 1000 x 1000 pixels %1 times over existing tile: %2\n").tqarg(testCount).tqarg(t.elapsed());
+
+}
+
+TQString rectRODefault(KisDoc * doc, TQ_UINT32 testCount)
+{
+ KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),""));
+ KisPaintDeviceSP l = img->activeDevice();
+;
+ TQTime t;
+ t.restart();
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, false);
+ while(! r.isDone())
+ {
+ ++r;
+ }
+ }
+
+ return TQString(" rect iterated read-only 1000 x 1000 pixels %1 times over default tile: %2\n").tqarg(testCount).tqarg(t.elapsed());
+
+
+}
+
+TQString rectRO(KisDoc * doc, TQ_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(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ p.end();
+
+ TQTime t;
+ t.restart();
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, false);
+ while(! r.isDone())
+ {
+ ++r;
+ }
+ }
+
+ return TQString(" rect iterated read-only 1000 x 1000 pixels %1 times over existing tile: %2\n").tqarg(testCount).tqarg(t.elapsed());
+
+}
+
+TQString rectWRDefault(KisDoc * doc, TQ_UINT32 testCount)
+{
+
+
+ KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),""));
+ KisPaintDeviceSP l = img->activeDevice();
+
+ TQTime t;
+ t.restart();
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, true);
+ while(! r.isDone())
+ {
+ ++r;
+ }
+ }
+
+ return TQString(" rect iterated writable 1000 x 1000 pixels %1 times over default tile: %2\n").tqarg(testCount).tqarg(t.elapsed());
+
+}
+
+TQString rectWR(KisDoc * doc, TQ_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(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ p.end();
+
+
+ TQTime t;
+ t.restart();
+
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, true);
+ while(! r.isDone())
+ {
+ ++r;
+ }
+ }
+
+
+ return TQString(" rect iterated writable 1000 x 1000 pixels %1 times over existing tile: %2\n").tqarg(testCount).tqarg(t.elapsed());
+
+
+}
+TQString PerfTest::iteratorTest(TQ_UINT32 testCount)
+{
+ TQString 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;
+
+
+}
+
+TQString PerfTest::paintViewTest(TQ_UINT32 testCount)
+{
+ TQString report = TQString("* 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(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ p.end();
+
+ TQTime t;
+ t.restart();
+
+#if USE_CALLGRIND
+ CALLGRIND_ZERO_STATS();
+#endif
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ m_view->getCanvasController()->updateCanvas(TQRect(0, 0, 512, 512));
+ }
+
+#if USE_CALLGRIND
+ CALLGRIND_DUMP_STATS();
+#endif
+
+ report = report.append(TQString(" painted a 512 x 512 image %1 times: %2 ms\n").tqarg(testCount).tqarg(t.elapsed()));
+
+ img->newLayer("layer 2", OPACITY_OPAQUE);
+ l = img->activeDevice();
+
+ p.begin(l.data());
+ p.fillRect(0, 0, 512, 512, KisColor(TQt::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(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()));
+ p.end();
+
+ t.restart();
+
+ for (TQ_UINT32 i = 0; i < testCount; ++i) {
+ m_view->getCanvasController()->updateCanvas(TQRect(0, 0, 512, 512));
+ }
+
+ report = report.append(TQString(" painted a 512 x 512 image with 3 layers %1 times: %2 ms\n").tqarg(testCount).tqarg(t.elapsed()));
+
+ return report;
+}
+
+TQString PerfTest::paintViewFPSTest()
+{
+ TQString report = TQString("* paintView (fps) test\n\n");
+
+ TQTime 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(TQString(" painted current view at %1 frames per second\n").tqarg(numViewsPainted));
+
+ return report;
+}
+
+#include "perftest.moc"
diff --git a/chalk/plugins/viewplugins/performancetest/perftest.h b/chalk/plugins/viewplugins/performancetest/perftest.h
new file mode 100644
index 00000000..5bae3c8c
--- /dev/null
+++ b/chalk/plugins/viewplugins/performancetest/perftest.h
@@ -0,0 +1,76 @@
+/*
+ * perftest.h -- Part of Chalk
+ *
+ * Copyright (c) 2005 Boudewijn Rempt <[email protected]>
+ *
+ * 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
+ TQ_OBJECT
+public:
+ PerfTest(TQObject *tqparent, const char *name, const TQStringList &);
+ virtual ~PerfTest();
+
+private slots:
+
+ void slotPerfTest();
+
+private:
+
+ TQString bltTest(TQ_UINT32 testCount);
+ TQString fillTest(TQ_UINT32 testCount);
+ TQString gradientTest(TQ_UINT32 testCount);
+ TQString pixelTest(TQ_UINT32 testCount);
+ TQString tqshapeTest(TQ_UINT32 testCount);
+ TQString layerTest(TQ_UINT32 testCount);
+ TQString scaleTest(TQ_UINT32 testCount);
+ TQString rotateTest(TQ_UINT32 testCount);
+ TQString renderTest(TQ_UINT32 restCount);
+ TQString selectionTest(TQ_UINT32 testCount);
+ TQString colorConversionTest(TQ_UINT32 testCount);
+ TQString filterTest(TQ_UINT32 testCount);
+ TQString readBytesTest(TQ_UINT32 testCount);
+ TQString writeBytesTest(TQ_UINT32 testCount);
+ TQString iteratorTest(TQ_UINT32 testCount);
+ TQString paintViewTest(TQ_UINT32 testCount);
+ TQString paintViewFPSTest();
+
+ TQString doBlit(const KisCompositeOp& op,
+ KisID cspace,
+ TQ_UINT8 opacity,
+ TQ_UINT32 testCount,
+ KisImageSP img);
+
+private:
+
+ KisView * m_view;
+ KisPainter * m_painter;
+
+};
+
+#endif // PERFTEST_H_
diff --git a/chalk/plugins/viewplugins/performancetest/perftest.rc b/chalk/plugins/viewplugins/performancetest/perftest.rc
new file mode 100644
index 00000000..de404a34
--- /dev/null
+++ b/chalk/plugins/viewplugins/performancetest/perftest.rc
@@ -0,0 +1,9 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui library="chalkperftest" version="1">
+<MenuBar>
+ <Menu name="Tools"><text>&amp;Tools</text>
+ <Separator/>
+ <Action name="perf_test"/>
+ </Menu>
+</MenuBar>
+</kpartgui> \ No newline at end of file
diff --git a/chalk/plugins/viewplugins/performancetest/wdg_perftest.ui b/chalk/plugins/viewplugins/performancetest/wdg_perftest.ui
new file mode 100644
index 00000000..7dc14f17
--- /dev/null
+++ b/chalk/plugins/viewplugins/performancetest/wdg_perftest.ui
@@ -0,0 +1,283 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>WdgPerfTest</class>
+<widget class="TQWidget">
+ <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="TQButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>grpPerfTest</cstring>
+ </property>
+ <property name="title">
+ <string>&amp;Performance Test</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" 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="TQCheckBox" 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="TQCheckBox" 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="TQCheckBox" 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="TQCheckBox" 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="TQCheckBox" 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="TQCheckBox" 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="TQCheckBox" 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="TQCheckBox" 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="TQCheckBox" 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="TQCheckBox" 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="TQCheckBox" 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="TQCheckBox" 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="TQCheckBox" 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="TQCheckBox" 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="TQCheckBox" 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="TQCheckBox" 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="TQLayoutWidget" row="18" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>tqlayout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>btnSelectAll</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Select All</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>btnDeselectAll</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Deselect All</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQCheckBox" 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>
+<tqlayoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+</includehints>
+</UI>