summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-04-22 04:47:24 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-04-22 04:47:24 (GMT)
commit2366667fc97eb6a56203b2dd7dac776ff4164abd (patch)
treeb2acb6cc6bfe475d7e619e4788973b61fff775e0 /tests/benchmarks
parent2c762f3b8b284a7c6dc0c499b7052013bad5b707 (diff)
downloadQt-2366667fc97eb6a56203b2dd7dac776ff4164abd.zip
Qt-2366667fc97eb6a56203b2dd7dac776ff4164abd.tar.gz
Qt-2366667fc97eb6a56203b2dd7dac776ff4164abd.tar.bz2
Initial import of kinetic-dui branch from the old kinetic
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/benchmarks.pro11
-rw-r--r--tests/benchmarks/qanimation/dummyanimation.cpp20
-rw-r--r--tests/benchmarks/qanimation/dummyanimation.h19
-rw-r--r--tests/benchmarks/qanimation/dummyobject.cpp25
-rw-r--r--tests/benchmarks/qanimation/dummyobject.h23
-rw-r--r--tests/benchmarks/qanimation/main.cpp173
-rw-r--r--tests/benchmarks/qanimation/qanimation.pro18
-rw-r--r--tests/benchmarks/qanimation/rectanimation.cpp58
-rw-r--r--tests/benchmarks/qanimation/rectanimation.h30
-rw-r--r--tests/benchmarks/qfxview/main.cpp182
-rw-r--r--tests/benchmarks/qfxview/qfxview.pro16
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/editor/data.xml44
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/background.pngbin0 -> 26508 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/background3.pngbin0 -> 37671 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/battery.pngbin0 -> 770 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/calendar-blur.pngbin0 -> 51439 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/calendar.pngbin0 -> 10153 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/callhistory-blur.pngbin0 -> 57023 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/callhistory.pngbin0 -> 13227 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/camera-blur.pngbin0 -> 50955 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/camera.pngbin0 -> 16126 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/contacts-blur.pngbin0 -> 51041 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/contacts.pngbin0 -> 12177 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/file-manager-blur.pngbin0 -> 45164 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/file-manager.pngbin0 -> 8858 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/fire.pngbin0 -> 1124 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-blue.pngbin0 -> 764 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-container.pngbin0 -> 536 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-front.pngbin0 -> 962 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-pink.pngbin0 -> 747 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-yellow.pngbin0 -> 775 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/ice.pngbin0 -> 1112 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/icon-reflection.pngbin0 -> 7123 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/internet-blur.pngbin0 -> 57126 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/internet.pngbin0 -> 24320 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-background1.pngbin0 -> 2831 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-border1.pngbin0 -> 926 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-border3.pngbin0 -> 10153 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-highlight.pngbin0 -> 3421 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/menubar.pngbin0 -> 741 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/messages-blur.pngbin0 -> 44556 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/messages.pngbin0 -> 11426 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/moon.pngbin0 -> 1027 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/sad.pngbin0 -> 1053 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/settings-blur.pngbin0 -> 50199 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/settings.pngbin0 -> 8697 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/signal.pngbin0 -> 739 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/smile.pngbin0 -> 1051 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/star.pngbin0 -> 262 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/sun.pngbin0 -> 1021 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/titlebar.pngbin0 -> 1041 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/pics/wifi.pngbin0 -> 782 bytes
-rw-r--r--tests/benchmarks/qfxview/testdata/tatwheel/tat-wheel.xml68
-rw-r--r--tests/benchmarks/qmlxmlparser/main.cpp96
-rw-r--r--tests/benchmarks/qmlxmlparser/qmlxmlparser.pro14
-rw-r--r--tests/benchmarks/qmlxmlparser/testdata/concept2.xml421
-rw-r--r--tests/benchmarks/qvariant/qvariant.pro1
-rw-r--r--tests/benchmarks/qvariant/tst_qvariant.cpp115
58 files changed, 1267 insertions, 67 deletions
diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro
index 8e2c243..937afa9 100644
--- a/tests/benchmarks/benchmarks.pro
+++ b/tests/benchmarks/benchmarks.pro
@@ -1,6 +1,7 @@
TEMPLATE = subdirs
SUBDIRS = containers-associative \
containers-sequential \
+ qanimation \
qbytearray \
qpainter \
qtestlib-simple events \
@@ -14,6 +15,14 @@ SUBDIRS = containers-associative \
qregion \
qvariant \
qwidget \
- qtwidgets
+ qtwidgets \
+ qmlxmlparser \
+ qfxview \
contains(QT_CONFIG, opengl): SUBDIRS += opengl
+
+# Tests which should run in Pulse
+PULSE_TESTS = \
+ qfxview \
+ qmlxmlparser \
+
diff --git a/tests/benchmarks/qanimation/dummyanimation.cpp b/tests/benchmarks/qanimation/dummyanimation.cpp
new file mode 100644
index 0000000..6fb1d0a
--- /dev/null
+++ b/tests/benchmarks/qanimation/dummyanimation.cpp
@@ -0,0 +1,20 @@
+#include "dummyanimation.h"
+#include "dummyobject.h"
+
+
+DummyAnimation::DummyAnimation(DummyObject *d) : m_dummy(d)
+{
+}
+
+void DummyAnimation::updateCurrentValue(const QVariant &value)
+{
+ if (state() == Stopped)
+ return;
+ if (m_dummy)
+ m_dummy->setRect(value.toRect());
+}
+
+void DummyAnimation::updateState(State state)
+{
+ Q_UNUSED(state);
+}
diff --git a/tests/benchmarks/qanimation/dummyanimation.h b/tests/benchmarks/qanimation/dummyanimation.h
new file mode 100644
index 0000000..fe6592b
--- /dev/null
+++ b/tests/benchmarks/qanimation/dummyanimation.h
@@ -0,0 +1,19 @@
+#include <QtGui>
+
+#ifndef _DUMMYANIMATION_H__
+
+class DummyObject;
+
+class DummyAnimation : public QVariantAnimation
+{
+public:
+ DummyAnimation(DummyObject *d);
+
+ void updateCurrentValue(const QVariant &value);
+ void updateState(State state);
+
+private:
+ DummyObject *m_dummy;
+};
+
+#endif \ No newline at end of file
diff --git a/tests/benchmarks/qanimation/dummyobject.cpp b/tests/benchmarks/qanimation/dummyobject.cpp
new file mode 100644
index 0000000..bd76388
--- /dev/null
+++ b/tests/benchmarks/qanimation/dummyobject.cpp
@@ -0,0 +1,25 @@
+#include "dummyobject.h"
+
+DummyObject::DummyObject()
+{
+}
+
+QRect DummyObject::rect() const
+{
+ return m_rect;
+}
+
+void DummyObject::setRect(const QRect &r)
+{
+ m_rect = r;
+}
+
+float DummyObject::opacity() const
+{
+ return m_opacity;
+}
+
+void DummyObject::setOpacity(float o)
+{
+ m_opacity = o;
+}
diff --git a/tests/benchmarks/qanimation/dummyobject.h b/tests/benchmarks/qanimation/dummyobject.h
new file mode 100644
index 0000000..c989662
--- /dev/null
+++ b/tests/benchmarks/qanimation/dummyobject.h
@@ -0,0 +1,23 @@
+#include <QtGui>
+
+#ifndef _DUMMYOBJECT_H__
+
+class DummyObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QRect rect READ rect WRITE setRect)
+ Q_PROPERTY(float opacity READ opacity WRITE setOpacity)
+public:
+ DummyObject();
+ QRect rect() const;
+ void setRect(const QRect &r);
+ float opacity() const;
+ void setOpacity(float);
+
+private:
+ QRect m_rect;
+ float m_opacity;
+};
+
+
+#endif \ No newline at end of file
diff --git a/tests/benchmarks/qanimation/main.cpp b/tests/benchmarks/qanimation/main.cpp
new file mode 100644
index 0000000..7bbcffb
--- /dev/null
+++ b/tests/benchmarks/qanimation/main.cpp
@@ -0,0 +1,173 @@
+#include <QtGui>
+#include <qtest.h>
+
+#include "dummyobject.h"
+#include "dummyanimation.h"
+#include "rectanimation.h"
+
+#define ITERATION_COUNT 10e3
+
+class tst_qanimation : public QObject
+{
+ Q_OBJECT
+private slots:
+ void itemAnimation();
+ void itemAnimation_data() { data();}
+ void itemPropertyAnimation();
+ void itemPropertyAnimation_data() { data();}
+ void dummyAnimation();
+ void dummyAnimation_data() { data();}
+ void dummyPropertyAnimation();
+ void dummyPropertyAnimation_data() { data();}
+ void rectAnimation();
+ void rectAnimation_data() { data();}
+
+ void floatAnimation_data() { data(); }
+ void floatAnimation();
+
+private:
+ void data();
+};
+
+
+void tst_qanimation::data()
+{
+ QTest::addColumn<bool>("paused");
+ QTest::newRow("NotRunning") << false;
+ QTest::newRow("Paused") << true;
+}
+
+void tst_qanimation::itemAnimation()
+{
+ QFETCH(bool, paused);
+ QGraphicsWidget item;
+
+ //first the item animation
+ {
+ QItemAnimation anim(&item, QItemAnimation::Position);
+ anim.setDuration(ITERATION_COUNT);
+ anim.setStartValue(QPointF(0,0));
+ anim.setEndValue(QPointF(ITERATION_COUNT,ITERATION_COUNT));
+ if (paused)
+ anim.pause();
+ QBENCHMARK {
+ for(int i = 0; i < anim.duration(); ++i) {
+ anim.setCurrentTime(i);
+ }
+ }
+ }
+}
+
+void tst_qanimation::itemPropertyAnimation()
+{
+ QFETCH(bool, paused);
+ QGraphicsWidget item;
+
+ //then the property animation
+ {
+ QPropertyAnimation anim(&item, "pos");
+ anim.setDuration(ITERATION_COUNT);
+ anim.setStartValue(QPointF(0,0));
+ anim.setEndValue(QPointF(ITERATION_COUNT,ITERATION_COUNT));
+ if (paused)
+ anim.pause();
+ QBENCHMARK {
+ for(int i = 0; i < ITERATION_COUNT; ++i) {
+ anim.setCurrentTime(i);
+ }
+ }
+ }
+
+}
+
+void tst_qanimation::dummyAnimation()
+{
+ QFETCH(bool, paused);
+ DummyObject dummy;
+
+ //first the dummy animation
+ {
+ DummyAnimation anim(&dummy);
+ anim.setDuration(ITERATION_COUNT);
+ anim.setStartValue(QRect(0, 0, 0, 0));
+ anim.setEndValue(QRect(0, 0, ITERATION_COUNT,ITERATION_COUNT));
+ if (paused)
+ anim.pause();
+ QBENCHMARK {
+ for(int i = 0; i < anim.duration(); ++i) {
+ anim.setCurrentTime(i);
+ }
+ }
+ }
+}
+
+void tst_qanimation::dummyPropertyAnimation()
+{
+ QFETCH(bool, paused);
+ DummyObject dummy;
+
+ //then the property animation
+ {
+ QPropertyAnimation anim(&dummy, "rect");
+ anim.setDuration(ITERATION_COUNT);
+ anim.setStartValue(QRect(0, 0, 0, 0));
+ anim.setEndValue(QRect(0, 0, ITERATION_COUNT,ITERATION_COUNT));
+ if (paused)
+ anim.pause();
+ QBENCHMARK {
+ for(int i = 0; i < ITERATION_COUNT; ++i) {
+ anim.setCurrentTime(i);
+ }
+ }
+ }
+}
+
+void tst_qanimation::rectAnimation()
+{
+ //this is the simplest animation you can do
+ QFETCH(bool, paused);
+ DummyObject dummy;
+
+ //then the property animation
+ {
+ RectAnimation anim(&dummy);
+ anim.setDuration(ITERATION_COUNT);
+ anim.setStartValue(QRect(0, 0, 0, 0));
+ anim.setEndValue(QRect(0, 0, ITERATION_COUNT,ITERATION_COUNT));
+ if (paused)
+ anim.pause();
+ QBENCHMARK {
+ for(int i = 0; i < ITERATION_COUNT; ++i) {
+ anim.setCurrentTime(i);
+ }
+ }
+ }
+}
+
+void tst_qanimation::floatAnimation()
+{
+ //this is the simplest animation you can do
+ QFETCH(bool, paused);
+ DummyObject dummy;
+
+ //then the property animation
+ {
+ QPropertyAnimation anim(&dummy, "opacity");
+ anim.setDuration(ITERATION_COUNT);
+ anim.setStartValue(0.f);
+ anim.setEndValue(1.f);
+ if (paused)
+ anim.pause();
+ QBENCHMARK {
+ for(int i = 0; i < ITERATION_COUNT; ++i) {
+ anim.setCurrentTime(i);
+ }
+ }
+ }
+}
+
+
+
+QTEST_MAIN(tst_qanimation)
+
+#include "main.moc"
diff --git a/tests/benchmarks/qanimation/qanimation.pro b/tests/benchmarks/qanimation/qanimation.pro
new file mode 100644
index 0000000..55cd75e
--- /dev/null
+++ b/tests/benchmarks/qanimation/qanimation.pro
@@ -0,0 +1,18 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qanimation
+DEPENDPATH += .
+INCLUDEPATH += .
+
+CONFIG += release
+#CONFIG += debug
+
+
+SOURCES += main.cpp \
+ dummyobject.cpp \
+ dummyanimation.cpp \
+ rectanimation.cpp
+
+HEADERS += dummyobject.h \
+ dummyanimation.h \
+ rectanimation.h
diff --git a/tests/benchmarks/qanimation/rectanimation.cpp b/tests/benchmarks/qanimation/rectanimation.cpp
new file mode 100644
index 0000000..66c7a33
--- /dev/null
+++ b/tests/benchmarks/qanimation/rectanimation.cpp
@@ -0,0 +1,58 @@
+#include "rectanimation.h"
+#include "dummyobject.h"
+
+static inline int interpolateInteger(int from, int to, qreal progress)
+{
+ return from + (to - from) * progress;
+}
+
+
+RectAnimation::RectAnimation(DummyObject *obj) : object(obj), dura(250)
+{
+}
+
+void RectAnimation::setEndValue(const QRect &rect)
+{
+ end = rect;
+}
+
+void RectAnimation::setStartValue(const QRect &rect)
+{
+ start = rect;
+}
+
+void RectAnimation::setDuration(int d)
+{
+ dura = d;
+}
+
+int RectAnimation::duration() const
+{
+ return dura;
+}
+
+
+void RectAnimation::updateCurrentTime(int msecs)
+{
+ qreal progress = easing.valueForProgress( qreal(msecs) / qreal(dura) );
+ QRect now;
+ now.setCoords(interpolateInteger(start.left(), end.left(), progress),
+ interpolateInteger(start.top(), end.top(), progress),
+ interpolateInteger(start.right(), end.right(), progress),
+ interpolateInteger(start.bottom(), end.bottom(), progress));
+
+ bool changed = (now != current);
+ if (changed)
+ current = now;
+
+ if (state() == Stopped)
+ return;
+
+ if (object)
+ object->setRect(current);
+}
+
+void RectAnimation::updateState(QAbstractAnimation::State state)
+{
+ Q_UNUSED(state);
+}
diff --git a/tests/benchmarks/qanimation/rectanimation.h b/tests/benchmarks/qanimation/rectanimation.h
new file mode 100644
index 0000000..c9770c4
--- /dev/null
+++ b/tests/benchmarks/qanimation/rectanimation.h
@@ -0,0 +1,30 @@
+#include <QtGui>
+
+#ifndef _RECTANIMATION_H__
+
+class DummyObject;
+
+//this class is even simpler than the dummy
+//and uses no QVariant at all
+class RectAnimation : public QAbstractAnimation
+{
+public:
+ RectAnimation(DummyObject *obj);
+
+ void setEndValue(const QRect &rect);
+ void setStartValue(const QRect &rect);
+
+ void setDuration(int d);
+ int duration() const;
+
+ virtual void updateCurrentTime(int msecs);
+ virtual void updateState(QAbstractAnimation::State state);
+
+private:
+ DummyObject *object;
+ QEasingCurve easing;
+ QRect start, end, current;
+ int dura;
+};
+
+#endif \ No newline at end of file
diff --git a/tests/benchmarks/qfxview/main.cpp b/tests/benchmarks/qfxview/main.cpp
new file mode 100644
index 0000000..787b113
--- /dev/null
+++ b/tests/benchmarks/qfxview/main.cpp
@@ -0,0 +1,182 @@
+#include <QFxView>
+#include <QmlBindContext>
+#include <QtGui>
+#include <QTest>
+#include <gfxtimeline.h>
+
+class tst_qfxview : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void render();
+ void render_data();
+
+private:
+ void waitForUpdates(QObject* obj, int howmany, int timeout = 10000);
+ bool eventFilter(QObject*, QEvent*);
+
+ QString testdata(QString const&);
+ QString readFile(QString const&);
+
+ int m_updateCount;
+ QEventLoop* m_eventLoop;
+ int m_updateLimit;
+};
+
+bool tst_qfxview::eventFilter(QObject*, QEvent* e)
+{
+ if (!m_eventLoop) {
+ return false;
+ }
+
+ if (e->type() == QEvent::UpdateRequest) {
+ m_updateCount++;
+ if (m_updateCount >= m_updateLimit) {
+ m_eventLoop->quit();
+ }
+ }
+
+ return false;
+}
+
+void tst_qfxview::waitForUpdates(QObject* obj, int howmany, int timeout)
+{
+ m_updateLimit = howmany;
+ m_updateCount = 0;
+
+ QEventLoop loop;
+ m_eventLoop = &loop;
+ if (timeout > 0)
+ QTimer::singleShot(timeout, &loop, SLOT(quit()));
+
+ obj->installEventFilter(this);
+ loop.exec();
+ obj->removeEventFilter(this);
+
+ m_eventLoop = 0;
+
+ if (m_updateCount < howmany) {
+ QFAIL(qPrintable(
+ QString("Didn't receive %1 updates within %2 milliseconds (only got %3)")
+ .arg(howmany).arg(timeout).arg(m_updateCount)
+ ));
+ }
+}
+
+void tst_qfxview::render()
+{
+ QFETCH(QString, xml);
+ QFETCH(QString, filename);
+ QFETCH(int, mode);
+
+ static const int FRAMES = 100;
+
+ QPixmap pm(800, 600);
+
+ QFxView view((QSimpleCanvas::CanvasMode)mode);
+ view.setFixedSize(pm.size());
+ if (!filename.isEmpty()) {
+ filename = testdata(filename);
+ xml = readFile(filename);
+ }
+ view.setXml(xml, filename);
+ QFileInfo fi(filename);
+ view.setPath(fi.path());
+
+ /* So we can reuse duiviewer examples... */
+ QObject *dummyData = QML::newInstance(fi.path() + "/editor/data.xml");
+ if (dummyData) {
+ QmlBindContext *ctxt = view.bindContext();
+ ctxt->setProperty("obj", dummyData);
+ ctxt->addDefaultObject(dummyData);
+ dummyData->setParent(&view);
+ }
+
+ view.show();
+ view.raise();
+ QTest::qWait(100);
+ view.activateWindow();
+ QTest::qWait(100);
+ QVERIFY(view.isActiveWindow());
+
+ view.execute();
+
+ /* Set internal GfxAppClock to consistent timing (every tick is 5 ms) */
+ {
+ GfxTimeLine tl;
+ tl.setMode(GfxTimeLine::Consistent);
+ }
+
+ /* Render FRAMES amount of updates */
+ QBENCHMARK {
+ waitForUpdates(&view, FRAMES);
+ if (QTest::currentTestFailed()) return;
+ }
+
+ //view.dumpTiming();
+}
+
+void tst_qfxview::render_data()
+{
+ QTest::addColumn<QString> ("xml");
+ QTest::addColumn<QString> ("filename");
+ QTest::addColumn<int> ("mode");
+
+ QTest::newRow("tatwheel-simplecanvas")
+ << QString()
+ << QString("tatwheel/tat-wheel.xml")
+ << int(QSimpleCanvas::SimpleCanvas)
+ ;
+
+ QTest::newRow("tatwheel-graphicsview")
+ << QString()
+ << QString("tatwheel/tat-wheel.xml")
+ << int(QSimpleCanvas::GraphicsView)
+ ;
+
+}
+
+QString tst_qfxview::readFile(QString const& filename)
+{
+ QFile file(filename);
+ if (!file.open(QIODevice::ReadOnly)) {
+ qFatal("Could not open %s: %s", qPrintable(filename), qPrintable(file.errorString()));
+ }
+ QByteArray ba = file.readAll();
+ return QString::fromLatin1(ba);
+}
+
+QString tst_qfxview::testdata(QString const& name)
+{
+#define _STR(X) #X
+#define STR(X) _STR(X)
+ return QString("%1/testdata/%2").arg(STR(SRCDIR)).arg(name);
+}
+
+int main(int argc, char** argv)
+{
+ /* Remove this when -graphicssystem raster is the default. */
+ bool explicit_graphicssystem = false;
+
+ QVector<const char*> args;
+ for (int i = 0; i < argc; ++i) {
+ if (!strcmp(argv[i], "-graphicssystem"))
+ explicit_graphicssystem = true;
+ args << argv[i];
+ }
+
+ if (!explicit_graphicssystem) {
+ args << "-graphicssystem" << "raster";
+ }
+
+ argc = args.count();
+ argv = const_cast<char**>(args.data());
+
+ QApplication app(argc, argv);
+
+ tst_qfxview test;
+ return QTest::qExec(&test, argc, argv);
+}
+
+#include "main.moc"
diff --git a/tests/benchmarks/qfxview/qfxview.pro b/tests/benchmarks/qfxview/qfxview.pro
new file mode 100644
index 0000000..e7dd168
--- /dev/null
+++ b/tests/benchmarks/qfxview/qfxview.pro
@@ -0,0 +1,16 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qfxview
+DEPENDPATH += .
+INCLUDEPATH += .
+
+CONFIG += release
+
+QT += declarative script
+
+DEFINES+=SRCDIR=\"$$PWD\"
+
+# Input
+SOURCES += \
+ main.cpp
+
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/editor/data.xml b/tests/benchmarks/qfxview/testdata/tatwheel/editor/data.xml
new file mode 100644
index 0000000..0a28d4f
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/editor/data.xml
@@ -0,0 +1,44 @@
+<Object>
+ <properties>
+ <Property name="appModel">
+ <ListModel>
+ <App>
+ <name>Internet</name>
+ <icon>pics/internet</icon>
+ </App>
+ <App>
+ <name>Calendar</name>
+ <icon>pics/calendar</icon>
+ </App>
+ <App>
+ <name>Contacts</name>
+ <icon>pics/contacts</icon>
+ </App>
+ <App>
+ <name>Camera</name>
+ <icon>pics/camera</icon>
+ </App>
+ <App>
+ <name>Messages</name>
+ <icon>pics/messages</icon>
+ </App>
+ <App>
+ <name>Call history</name>
+ <icon>pics/callhistory</icon>
+ </App>
+ <App>
+ <name>File manager</name>
+ <icon>pics/file-manager</icon>
+ </App>
+ <App>
+ <name>Settings</name>
+ <icon>pics/settings</icon>
+ </App>
+ <App>
+ <name>Call history</name>
+ <icon>pics/callhistory</icon>
+ </App>
+ </ListModel>
+ </Property>
+ </properties>
+</Object>
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/background.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/background.png
new file mode 100644
index 0000000..4b6f56e
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/background.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/background3.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/background3.png
new file mode 100644
index 0000000..66cb522
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/background3.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/battery.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/battery.png
new file mode 100644
index 0000000..4bd03d4
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/battery.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/calendar-blur.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/calendar-blur.png
new file mode 100644
index 0000000..136ae80
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/calendar-blur.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/calendar.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/calendar.png
new file mode 100644
index 0000000..0e63f1c
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/calendar.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/callhistory-blur.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/callhistory-blur.png
new file mode 100644
index 0000000..5ed1c99
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/callhistory-blur.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/callhistory.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/callhistory.png
new file mode 100644
index 0000000..6c26405
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/callhistory.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/camera-blur.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/camera-blur.png
new file mode 100644
index 0000000..7285278
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/camera-blur.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/camera.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/camera.png
new file mode 100644
index 0000000..710907f
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/camera.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/contacts-blur.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/contacts-blur.png
new file mode 100644
index 0000000..5ba94c7
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/contacts-blur.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/contacts.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/contacts.png
new file mode 100644
index 0000000..78bb885
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/contacts.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/file-manager-blur.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/file-manager-blur.png
new file mode 100644
index 0000000..6ec1d55
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/file-manager-blur.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/file-manager.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/file-manager.png
new file mode 100644
index 0000000..e58a39b
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/file-manager.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/fire.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/fire.png
new file mode 100644
index 0000000..e1b40cf
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/fire.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-blue.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-blue.png
new file mode 100644
index 0000000..3cb05ef
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-blue.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-container.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-container.png
new file mode 100644
index 0000000..dd34cbd
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-container.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-front.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-front.png
new file mode 100644
index 0000000..bed9e60
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-front.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-pink.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-pink.png
new file mode 100644
index 0000000..b84ee88
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-pink.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-yellow.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-yellow.png
new file mode 100644
index 0000000..4108ea3
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-yellow.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/ice.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/ice.png
new file mode 100644
index 0000000..8191fbc
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/ice.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/icon-reflection.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/icon-reflection.png
new file mode 100644
index 0000000..6c19e71
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/icon-reflection.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/internet-blur.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/internet-blur.png
new file mode 100644
index 0000000..32dc564
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/internet-blur.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/internet.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/internet.png
new file mode 100644
index 0000000..820ce34
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/internet.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-background1.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-background1.png
new file mode 100644
index 0000000..e84dc11
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-background1.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-border1.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-border1.png
new file mode 100644
index 0000000..e6dea40
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-border1.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-border3.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-border3.png
new file mode 100644
index 0000000..1d8a571
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-border3.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-highlight.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-highlight.png
new file mode 100644
index 0000000..3817b08
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-highlight.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/menubar.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/menubar.png
new file mode 100644
index 0000000..1b0380a
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/menubar.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/messages-blur.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/messages-blur.png
new file mode 100644
index 0000000..3c62d53
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/messages-blur.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/messages.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/messages.png
new file mode 100644
index 0000000..a452d58
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/messages.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/moon.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/moon.png
new file mode 100644
index 0000000..cc3a3bc
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/moon.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/sad.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/sad.png
new file mode 100644
index 0000000..de90bc4
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/sad.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/settings-blur.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/settings-blur.png
new file mode 100644
index 0000000..f175161
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/settings-blur.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/settings.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/settings.png
new file mode 100644
index 0000000..6e72796
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/settings.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/signal.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/signal.png
new file mode 100644
index 0000000..7af4c24
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/signal.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/smile.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/smile.png
new file mode 100644
index 0000000..f6bf09f
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/smile.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/star.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/star.png
new file mode 100644
index 0000000..defbde5
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/star.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/sun.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/sun.png
new file mode 100644
index 0000000..b2092f1
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/sun.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/titlebar.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/titlebar.png
new file mode 100644
index 0000000..40484d0
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/titlebar.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/pics/wifi.png b/tests/benchmarks/qfxview/testdata/tatwheel/pics/wifi.png
new file mode 100644
index 0000000..ada1d3b
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/pics/wifi.png
Binary files differ
diff --git a/tests/benchmarks/qfxview/testdata/tatwheel/tat-wheel.xml b/tests/benchmarks/qfxview/testdata/tatwheel/tat-wheel.xml
new file mode 100644
index 0000000..6da6608
--- /dev/null
+++ b/tests/benchmarks/qfxview/testdata/tatwheel/tat-wheel.xml
@@ -0,0 +1,68 @@
+<Item id="Page" width="800" height="600">
+ <resources>
+ <Component id="AppDelegate">
+ <Item id="Wrapper" x="0" width="204" height="204" scale="{PathView.scale}" z="{PathView.z}">
+ <Item width="{AppIcon.width}" height="{AppIcon.height}" anchors.horizontalCenter="{parent.horizontalCenter}" >
+ <BlendedImage id="AppIcon" width="240" height="240" primaryFile="{icon + '.png'}" secondaryFile="{icon + '-blur.png'}" anchors.horizontalCenter="{parent.horizontalCenter}" blend="{1 - Wrapper.PathView.opacity}" />
+ </Item>
+ <Text id="AppName" anchors.top="{Wrapper.bottom}" anchors.topMargin="25"
+ anchors.horizontalCenter="{parent.horizontalCenter}" text="{name}" font.bold="true" font.size="26" color="white"/>
+ <states>
+ <State name="HideName" when="{index != pathView.currentIndex}">
+ <SetProperty target="{AppName}" property="opacity" value="0"/>
+ </State>
+ </states>
+ <transitions>
+ <Transition>
+ <NumericAnimation properties="opacity" duration="500"/>
+ </Transition>
+ </transitions>
+ </Item>
+ </Component>
+ </resources>
+
+ <Image id="Background" opaque="true" file="pics/background.png" anchors.fill="{parent}"/>
+
+ <Item y="0" id="Wheel">
+ <Script>
+ <![CDATA[
+ function prevItem() {
+ if (Applications.currentIndex > 0)
+ Applications.currentIndex--;
+ else
+ Applications.currentIndex = Applications.count - 1;
+ }
+ function nextItem() {
+ if (Applications.currentIndex < Applications.count - 1)
+ Applications.currentIndex++;
+ else
+ Applications.currentIndex = 0;
+ }
+ ]]>
+ </Script>
+ <PathView id="Applications" model="{appModel}" width="800" height="600" delegate="{AppDelegate}" focusable="true">
+ <path>
+ <Path startX="320" startY="350">
+ <PathAttribute name="scale" value="1.0"/>
+ <PathAttribute name="z" value="50"/>
+ <PathAttribute name="opacity" value="1"/>
+ <PathQuad x="320" y="150" controlX="740" controlY="250" />
+ <PathAttribute name="scale" value="0.1"/>
+ <PathAttribute name="z" value="0"/>
+ <PathAttribute name="opacity" value="-0.5"/>
+ <PathQuad x="320" y="350" controlX="-100" controlY="250"/>
+ </Path>
+ </path>
+ <currentIndex>
+ <SerialAnimation running="true" repeat="true">
+ <NumericAnimation target="{Applications}" from="0" to="{Applications.count}" duration="1000" />
+ </SerialAnimation>
+ </currentIndex>
+ </PathView>
+ <transitions>
+ <Transition>
+ <NumericAnimation properties="x,y,scale,opacity" duration="250"/>
+ </Transition>
+ </transitions>
+ </Item>
+</Item>
diff --git a/tests/benchmarks/qmlxmlparser/main.cpp b/tests/benchmarks/qmlxmlparser/main.cpp
new file mode 100644
index 0000000..17dc7f3
--- /dev/null
+++ b/tests/benchmarks/qmlxmlparser/main.cpp
@@ -0,0 +1,96 @@
+#include <QTest>
+#include <QtXml>
+#include <QmlComponent>
+
+class tst_qmlxmlparser : public QObject
+{
+ Q_OBJECT
+
+public:
+ enum XmlParser { ParserQXmlStreamReader = 0, ParserQmlComponent };
+
+private slots:
+ void parse();
+ void parse_data();
+
+private:
+ QString readFile(QString const&);
+};
+
+/*
+ Benchmark the parsing of Qml, using QXmlStreamReader as a baseline.
+ This gives an idea of the overhead Qml imposes over the top of plain XML parsing.
+*/
+void tst_qmlxmlparser::parse()
+{
+ QFETCH(QString, xml);
+ QFETCH(int, parser);
+
+ if (parser == ParserQXmlStreamReader) {
+ QBENCHMARK {
+ QXmlStreamReader parser(xml);
+ while (!parser.atEnd()) parser.readNext();
+ }
+ }
+ else if (parser == ParserQmlComponent) {
+ QByteArray ba = xml.toLatin1();
+ QBENCHMARK {
+ QmlComponent qmlc(ba);
+ }
+ }
+}
+
+void tst_qmlxmlparser::parse_data()
+{
+ QTest::addColumn<QString>("xml");
+ QTest::addColumn<int> ("parser");
+
+ QTest::newRow("empty-qxml")
+ << QString()
+ << (int)ParserQXmlStreamReader;
+
+ QTest::newRow("empty-qml")
+ << QString()
+ << (int)ParserQmlComponent;
+
+ {
+ QString xml = QString::fromLatin1("<Item prop1=\"foo\"><Prop2 value=\"bar\"/></Item>");
+
+ QTest::newRow("simple-qxml")
+ << xml
+ << (int)ParserQXmlStreamReader;
+
+ QTest::newRow("simple-qml")
+ << xml
+ << (int)ParserQmlComponent;
+ }
+
+ {
+ QString xml = readFile("concept2.xml");
+
+ QTest::newRow("concept2-qxml")
+ << xml
+ << (int)ParserQXmlStreamReader;
+
+ QTest::newRow("concept2-qml")
+ << xml
+ << (int)ParserQmlComponent;
+ }
+}
+
+QString tst_qmlxmlparser::readFile(QString const& filename)
+{
+#define _STR(X) #X
+#define STR(X) _STR(X)
+ QFile file(QString("%1/testdata/%2").arg(STR(SRCDIR)).arg(filename));
+ if (!file.open(QIODevice::ReadOnly)) {
+ qFatal("Could not open %s: %s", qPrintable(filename), qPrintable(file.errorString()));
+ }
+ QByteArray ba = file.readAll();
+ return QString::fromLatin1(ba);
+}
+
+
+QTEST_MAIN(tst_qmlxmlparser)
+
+#include "main.moc"
diff --git a/tests/benchmarks/qmlxmlparser/qmlxmlparser.pro b/tests/benchmarks/qmlxmlparser/qmlxmlparser.pro
new file mode 100644
index 0000000..e31c692
--- /dev/null
+++ b/tests/benchmarks/qmlxmlparser/qmlxmlparser.pro
@@ -0,0 +1,14 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qmlxmlparser
+DEPENDPATH += .
+INCLUDEPATH += .
+
+CONFIG += release
+
+QT += declarative xml
+
+DEFINES+=SRCDIR=\"$$PWD\"
+
+# Input
+SOURCES += main.cpp
diff --git a/tests/benchmarks/qmlxmlparser/testdata/concept2.xml b/tests/benchmarks/qmlxmlparser/testdata/concept2.xml
new file mode 100644
index 0000000..67c625d
--- /dev/null
+++ b/tests/benchmarks/qmlxmlparser/testdata/concept2.xml
@@ -0,0 +1,421 @@
+<Item id="Screen" width="320" height="240">
+ <Item id="Main" anchors.fill="{parent}">
+
+ <Script source="concept2.js"/>
+
+ <resources>
+
+ <ListModel id="TabModel">
+ <ListItem>
+ <name>Favorites</name>
+ <image>pics/favorites.png</image>
+ <highlightColor>#BE0000</highlightColor>
+ </ListItem>
+ <ListItem>
+ <name>Phone</name>
+ <image>pics/calls.png</image>
+ <highlightColor>#BE00B5</highlightColor>
+ </ListItem>
+ <ListItem>
+ <name>Messages</name>
+ <image>pics/messaging.png</image>
+ <highlightColor>#1000BE</highlightColor>
+ </ListItem>
+ <ListItem>
+ <name>Applications</name>
+ <image>pics/apps.png</image>
+ <highlightColor>#00AEBE</highlightColor>
+ </ListItem>
+ <ListItem>
+ <name>Media Center</name>
+ <image>pics/media.png</image>
+ <highlightColor>#06BE00</highlightColor>
+ </ListItem>
+ <ListItem>
+ <name>Settings</name>
+ <image>pics/settings.png</image>
+ <highlightColor>#CF7900</highlightColor>
+ </ListItem>
+ </ListModel>
+
+ <ListModel id="ListModel1">
+ <ListItem>
+ <name>Games</name>
+ </ListItem>
+ <ListItem>
+ <name>Contacts</name>
+ </ListItem>
+ <ListItem>
+ <name>Clock</name>
+ </ListItem>
+ </ListModel>
+
+ <ListModel id="ListModel2">
+ <ListItem>
+ <name>Contacts</name>
+ </ListItem>
+ <ListItem>
+ <name>Missed Calls</name>
+ </ListItem>
+ <ListItem>
+ <name>Received Calls</name>
+ </ListItem>
+ <ListItem>
+ <name>Dialed Numbers</name>
+ </ListItem>
+ </ListModel>
+
+ <ListModel id="ListModel3">
+ <ListItem>
+ <name>Inbox</name>
+ </ListItem>
+ <ListItem>
+ <name>Sent</name>
+ </ListItem>
+ <ListItem>
+ <name>Drafts</name>
+ </ListItem>
+ <ListItem>
+ <name>Email</name>
+ </ListItem>
+ </ListModel>
+
+ <ListModel id="ListModel4">
+ <ListItem>
+ <name>Calculator</name>
+ </ListItem>
+ <ListItem>
+ <name>Calendar</name>
+ </ListItem>
+ <ListItem>
+ <name>Camera</name>
+ </ListItem>
+ <ListItem>
+ <name>Clock</name>
+ </ListItem>
+ <ListItem>
+ <name>Notes</name>
+ </ListItem>
+ <ListItem>
+ <name>Web Browser</name>
+ </ListItem>
+ </ListModel>
+
+ <ListModel id="ListModel5">
+ <ListItem>
+ <name>Pictures</name>
+ </ListItem>
+ <ListItem>
+ <name>Music</name>
+ </ListItem>
+ <ListItem>
+ <name>Videos</name>
+ </ListItem>
+ <ListItem>
+ <name>Games</name>
+ </ListItem>
+ </ListModel>
+
+ <ListModel id="ListModel6">
+ <ListItem>
+ <name>Appearance</name>
+ </ListItem>
+ <ListItem>
+ <name>Bluetooth</name>
+ </ListItem>
+ <ListItem>
+ <name>Date/Time</name>
+ </ListItem>
+ <ListItem>
+ <name>Power Management</name>
+ </ListItem>
+ </ListModel>
+
+ <ListModel id="AlarmsModel">
+ <ListItem>
+ <time>7:30</time>
+ <label>Wake Up!</label>
+ <repeat>Weekdays</repeat>
+ <status>on</status>
+ </ListItem>
+ <ListItem>
+ <time>9:00</time>
+ <label>Exercise</label>
+ <repeat>Weekends</repeat>
+ <status>on</status>
+ </ListItem>
+ </ListModel>
+
+ <Component id="TabDelegate">
+ <Item width="53" height="36">
+ <Image file="{image}" x="15" y="7" />
+ <ColorAnimation target="{TitleBar}" property="highlightColor" running="{index == TabListView.currentIndex}" to="{highlightColor}" duration="300"/>
+ <NumericAnimation target="{Lists}" property="x" running="{index == TabListView.currentIndex}" to="{-TabListView.currentIndex * 320}" duration="300" easing="easeInOutQuad"/>
+ <Bind target="{Title}" property="text" value="{if (index == TabListView.currentIndex) name;}"/>
+ </Item>
+ </Component>
+
+ <Component id="TabHighlight">
+ <Image file="titlebar-selection.png"/>
+ </Component>
+
+ <Component id="ListDelegate">
+ <Item x="12" width="{Main.width}" height="30">
+ <Text id="AppNameBlack" text="{name}" width="{parent.width}" height="{parent.height}" vAlign="AlignVCenter" font.size="10" font.bold="true" font.family="Nokia Standard Multiscript"/>
+ <Text id="AppNameWhite" text="{name}" width="{parent.width}" height="{parent.height}" vAlign="AlignVCenter" font.size="10" font.bold="true" font.family="Nokia Standard Multiscript" color="white" opacity="0"/>
+ <states>
+ <State name="currentItem" when="{list.currentIndex == index}">
+ <SetProperty target="{AppNameBlack}" property="opacity" value="0"/>
+ <SetProperty target="{AppNameWhite}" property="opacity" value="1"/>
+ </State>
+ </states>
+ <transitions>
+ <Transition>
+ <NumericAnimation property="opacity" duration="250"/>
+ </Transition>
+ </transitions>
+ </Item>
+ </Component>
+
+ <Component id="ContactDelegate">
+ <KeyActions id="Wrapper" width="{Main.width}" focusable="true" height="30"
+ leftArrow="PhoneDetails.currentState='BusinessDetails'"
+ rightArrow="PhoneDetails.currentState='BusinessDetails'">
+
+ <!--<Rect id="Highlight" width="{Main.width - 6}" x="3" radius="4" height="60" color="black" opacity="0"/>-->
+ <Image id="Portrait" file="{portrait}" x="10" y="5" opacity="0"/>
+ <Item id="ContactName" x="18" y="5">
+ <Text id="NameBlack" text="{firstName + ' '+ lastName}" font.size="10" font.bold="true" font.family="Nokia Standard Multiscript"/>
+ <Text id="NameWhite" text="{firstName + ' '+ lastName}" font.size="10" font.bold="true" font.family="Nokia Standard Multiscript" color="white" opacity="0"/>
+ </Item>
+ <Item id="PhoneDetails" opacity="0">
+ <Item id="HomeDetails">
+ <Image file="pics/homephone.png" x="75" y="30"/>
+ <Text text="{homephone}" x="105" y="33" font.size="10" font.bold="true" font.family="Nokia Standard Multiscript" color="white"/>
+ </Item>
+ <Item id="BusinessDetails" opacity="0">
+ <Image file="pics/businessmobile.png" x="75" y="30"/>
+ <Text text="{businessmobile}" x="105" y="33" font.size="10" font.bold="true" font.family="Nokia Standard Multiscript" color="white"/>
+ </Item>
+ <states>
+ <State name="BusinessDetails">
+ <SetProperty target="{HomeDetails}" property="opacity" value="0"/>
+ <SetProperty target="{BusinessDetails}" property="opacity" value="1"/>
+ <SetProperties target="{Wrapper}" leftArrow="PhoneDetails.currentState=''" rightArrow="PhoneDetails.currentState=''" />
+ </State>
+ </states>
+ <transitions>
+ <Transition>
+ <NumericAnimation properties="opacity" duration="250"/>
+ </Transition>
+ </transitions>
+ </Item>
+ <states>
+ <State name="currentItem" when="{list.currentIndex == index}">
+ <SetProperty target="{Wrapper}" property="focus" value="true"/>
+ <SetProperty target="{NameBlack}" property="opacity" value="0"/>
+ <SetProperty target="{NameWhite}" property="opacity" value="1"/>
+ <SetProperty target="{Wrapper}" property="height" value="60" />
+ <SetProperty target="{Portrait}" property="opacity" value="1" />
+ <SetProperty target="{ContactName}" property="x" value="70" />
+ <SetProperty target="{PhoneDetails}" property="opacity" value="1" />
+ <SetProperty target="{Highlight}" property="opacity" value="1" />
+ </State>
+ </states>
+ <transitions>
+ <Transition>
+ <NumericAnimation properties="opacity,height,y,x" duration="250"/>
+ </Transition>
+ </transitions>
+ </KeyActions>
+ </Component>
+
+ <Component id="ListHighlight">
+ <Item>
+ <Rect width="{Main.width-6}" x="-9" height="{parent.height}" color="#242424" radius="4"/>
+ </Item>
+ </Component>
+
+ <Component id="AlarmsDelegate">
+ <KeyActions id="Wrapper" width="{Main.width}" focusable="true" height="60" escape="Wrapper.currentState = 'currentItem'" return="Wrapper.currentState = 'EditMode'">
+ <Image file="pics/alarm.png" x="10" anchors.verticalCenter="{parent.verticalCenter}"/>
+ <Text id="TimeBlack" text="{time}" anchors.verticalCenter="{parent.verticalCenter}" x="50" font.size="16" font.bold="true" font.family="Nokia Large"/>
+ <Text id="TimeWhite" text="{time}" anchors.verticalCenter="{parent.verticalCenter}" x="50" font.size="16" font.bold="true" font.family="Nokia Large" color="white" opacity="0"/>
+ <Text id="LabelBlack" text="{label}" x="110" y="4" font.size="10" font.bold="true" font.family="Nokia Standard Multiscript"/>
+ <Text id="LabelWhite" text="{label}" x="110" y="4" font.size="10" font.bold="true" font.family="Nokia Standard Multiscript" color="white" opacity="0"/>
+ <Text id="RepeatBlack" text="{repeat}" x="110" y="25" font.size="10" font.family="Nokia Standard Multiscript"/>
+ <Text id="RepeatWhite" text="{repeat}" x="110" y="25" font.size="10" font.family="Nokia Standard Multiscript" color="white" opacity="0"/>
+ <states>
+ <State name="currentItem" when="{list.currentIndex == index}">
+ <SetProperty target="{Wrapper}" property="focus" value="true"/>
+ <SetProperty target="{TimeBlack}" property="opacity" value="0"/>
+ <SetProperty target="{TimeWhite}" property="opacity" value="1"/>
+ <SetProperty target="{LabelBlack}" property="opacity" value="0"/>
+ <SetProperty target="{LabelWhite}" property="opacity" value="1"/>
+ <SetProperty target="{RepeatBlack}" property="opacity" value="0"/>
+ <SetProperty target="{RepeatWhite}" property="opacity" value="1"/>
+ </State>
+ <State name="EditMode" extends="currentItem">
+ <SetProperty target="{list}" property="x" value="-320"/>
+ <SetProperty target="{AlarmDetails}" property="active" value="true"/>
+ </State>
+ </states>
+ <transitions>
+ <Transition>
+ <NumericAnimation properties="opacity,height,y,x,yPosition" duration="250"/>
+ </Transition>
+ </transitions>
+ </KeyActions>
+ </Component>
+
+ </resources>
+
+ <Image id="Background" file="pics/background.png" opaque="true"/>
+
+ <Item id="TitleBar">
+ <properties>
+ <Property name="index" value="0" type="Int"/>
+ <Property name="highlightColor" type="Color"/>
+ </properties>
+ <Rect id="TitleBarBackground" y="0" gradientColor="black" color="{'#676767'}" width="320" height="24"/>
+ <Image id="HeaderShadow" file="pics/header-shadow.png" anchors.top="{TitleBarBackground.bottom}" width="320"/>
+ <Item id="TitleBarContent" width="320" height="24">
+ <Text id="Operator" text="Qt Extended" x="5" style="Sunken" styleColor="#333333" width="155" height="{parent.height}" color="white" font.size="10" font.bold="true" font.family="Nokia Standard Multiscript" vAlign="AlignVCenter"/>
+ <Text id="Title" text="" x="5" style="Sunken" styleColor="#333333" width="155" height="{parent.height}" color="white" font.size="10" font.bold="true" font.family="Nokia Standard Multiscript" vAlign="AlignVCenter" opacity="0"/>
+ <Text id="Time" text="10:52 AM" style="Sunken" styleColor="#333333" x="160" width="155" height="{parent.height}" color="white" font.size="10" font.bold="true" font.family="Nokia Standard Multiscript" hAlign="AlignRight" vAlign="AlignVCenter"/>
+ </Item>
+ <ListView id="TabListView" currentIndex="{TitleBar.index}" y="24" width="320" height="36" model="{TabModel}" delegate="{TabDelegate}" highlight="{TabHighlight}" clip="true" currentItemMode="Click" orientation="Qt::Horizontal" opacity="0"/>
+ <states>
+ <State name="coloredState">
+ <SetProperty target="{TitleBarBackground}" property="color" binding="TitleBar.highlightColor" />
+ <SetProperty target="{MenuBarBackground}" property="color" binding="TitleBar.highlightColor" />
+ </State>
+ <State name="Expanded" extends="coloredState">
+ <SetProperty target="{TitleBarBackground}" property="height" value="60"/>
+ <SetProperty target="{TabListView}" property="opacity" value="1"/>
+ <SetProperty target="{Lists}" property="y" value="63"/>
+ <SetProperty target="{Title}" property="opacity" value="1"/>
+ <SetProperty target="{Operator}" property="x" value="-155"/>
+ <SetProperty target="{ListBackground}" property="y" value="60"/>
+ <SetProperty target="{List1}" property="focus" value="true"/>
+ <SetProperty target="{HeaderShadow}" property="opacity" value="0"/>
+ <SetProperty target="{ContextKey2}" property="text" value="Select"/>
+ <SetProperty target="{ContextKey3}" property="text" value="Back"/>
+ </State>
+ <State name="ApplicationLaunched" extends="coloredState">
+ <SetProperty target="{Lists}" property="opacity" value="0"/>
+ <SetProperty target="{Title}" property="opacity" value="1"/>
+ <SetProperty target="{Operator}" property="x" value="-155"/>
+ <SetProperty target="{ListBackground}" property="y" value="24"/>
+ <SetProperty target="{ContextKey2}" property="text" value="Select"/>
+ <SetProperty target="{ContextKey3}" property="text" value="Back"/>
+ </State>
+ <State name="ContactsLaunched" extends="ApplicationLaunched">
+ <SetProperty target="{ContactList}" property="focus" value="true"/>
+ <SetProperty target="{ContactList}" property="opacity" value="1"/>
+ </State>
+ <State name="AlarmsLaunched" extends="ApplicationLaunched">
+ <SetProperty target="{AlarmList}" property="focus" value="true"/>
+ <SetProperty target="{AlarmList}" property="opacity" value="1"/>
+ </State>
+ </states>
+ <transitions>
+ <Transition fromState="*" toState="Expanded" reversible="true">
+ <SerialAnimation>
+ <NumericAnimation properties="x,y,height" easing="easeInOutQuad" duration="300"/>
+ <NumericAnimation properties="opacity" duration="200"/>
+ </SerialAnimation>
+ </Transition>
+ <Transition fromState="Expanded" toState="ContactsLaunched" reversible="true">
+ <NumericAnimation properties="x,y,height,opacity" easing="easeInOutQuad" duration="300"/>
+ </Transition>
+ <Transition fromState="Expanded" toState="AlarmsLaunched" reversible="true">
+ <NumericAnimation properties="x,y,height,opacity" easing="easeInOutQuad" duration="300"/>
+ </Transition>
+ </transitions>
+ </Item>
+
+ <Rect id="ListBackground" color="#cdcdcd" y="237" width="320" height="216"/>
+ <Item id="Lists" y="240" width="320" height="150" onKeyPress="keyPressed(event.key)">
+ <ListView id="List1" focusable="true" focus="true" width="{parent.width}" height="150" model="{ListModel1}" delegate="{ListDelegate}" clip="true" currentItemMode="Click" highlight="{ListHighlight}" wrap="true"/>
+ <ListView id="List2" focusable="true" x="320" width="{parent.width}" height="150" model="{ListModel2}" delegate="{ListDelegate}" clip="true" currentItemMode="Click" highlight="{ListHighlight}" wrap="true"/>
+ <ListView id="List3" focusable="true" x="640" width="{parent.width}" height="150" model="{ListModel3}" delegate="{ListDelegate}" clip="true" currentItemMode="Click" highlight="{ListHighlight}" wrap="true"/>
+ <ListView id="List4" focusable="true" x="960" width="{parent.width}" height="150" model="{ListModel4}" delegate="{ListDelegate}" clip="true" currentItemMode="Click" highlight="{ListHighlight}" wrap="true"/>
+ <ListView id="List5" focusable="true" x="1280" width="{parent.width}" height="150" model="{ListModel5}" delegate="{ListDelegate}" clip="true" currentItemMode="Click" highlight="{ListHighlight}" wrap="true"/>
+ <ListView id="List6" focusable="true" x="1600" width="{parent.width}" height="150" model="{ListModel6}" delegate="{ListDelegate}" clip="true" currentItemMode="Click" highlight="{ListHighlight}" wrap="true"/>
+ </Item>
+
+ <ListView id="ContactList" model="{contactModel}" y="27" height="186" width="320" opacity="0" clip="true" focusable="true" focus="false" delegate="{ContactDelegate}" currentItemMode="Click" onKeyPress="contactsKeyPressed(event.key)">
+ <children>
+ <Rect color="#242424" radius="4" width="320" height="60" id="ContactListRect" y="{ContactList.currentIndex * 30}">
+ <Text text="{parent.y}" color="white" anchors.right="{parent.right}"/>
+ <y>
+ <Behaviour>
+ <NumericAnimation property="y" duration="250" />
+ </Behaviour>
+ </y>
+ </Rect>
+ </children>
+ </ListView>
+ <ListView id="AlarmList" model="{AlarmsModel}" y="27" height="186" width="320" clip="true" focusable="true" focus="false" delegate="{AlarmsDelegate}" highlight="{ListHighlight}" currentItemMode="Click" onKeyPress="alarmKeyPressed(event.key)" opacity="0"/>
+ <FocusPanel id="AlarmDetails" anchors.left="{AlarmList.right}" y="27" height="186" width="320" active="false">
+ <VerticalLayout anchors.fill="{parent}">
+ <EditableText id="et1" label="Label" focus="true" text="Wake Up!" height="40" width="{AlarmList.width}"/>
+ <EditableText id="et2" label="Time" text="07:45" height="40" width="{AlarmList.width}"/>
+ <EditableText id="et3" label="Frequency" text="Weekdays" height="40" width="{AlarmList.width}"/>
+ </VerticalLayout>
+ </FocusPanel>
+
+<!-- <Clock id="Clock" x="70" y="30" opacity="0" hour="2" minute="59" focusable="true" onKeyPress="keyPressed(event.key)"/>-->
+
+ <Rect id="MenuBarBackground" gradientColor="black" color="{'#676767'}" y="216" width="320" height="24" />
+ <FocusPanel active="{currentState=='ToolBar'}" id="MenuBar" y="216" width="320" height="24">
+ <KeyActions c="MenuBar.currentState=''" focusable="true" focus="true" />
+ <Rect width="{MenuBar.width}" height="1" color="black" opacity="0.2"/>
+ <Item id="ContextKeys" anchors.fill="{parent}">
+ <states>
+ <State name="Hidden" when="{QuickMenu.expanded == true}">
+ <SetProperty target="{ContextKeys}" property="opacity" value="0" />
+ </State>
+ </states>
+ <transitions>
+ <Transition>
+ <NumericAnimation properties="opacity" duration="300" />
+ </Transition>
+ </transitions>
+
+ <SoftText id="ContextKey1" text="Options" anchors.verticalCenter="{parent.verticalCenter}" x="35" />
+ <SoftText id="ContextKey2" text="Menu" anchors.horizontalCenter="{parent.horizontalCenter}" anchors.verticalCenter="{parent.verticalCenter}" />
+ <SoftText id="ContextKey3" text="" anchors.verticalCenter="{parent.verticalCenter}" x="290" />
+ <MouseRegion height="{parent.height}" width="106" onClick="contextKey1Cliked();"/>
+ <MouseRegion height="{parent.height}" x="107" width="106" onClick="contextKey2Cliked();"/>
+ <MouseRegion height="{parent.height}" x="213" width="106" onClick="contextKey3Cliked();"/>
+ </Item>
+ <HorizontalLayout id="ToolBar" opacity="0">
+ <ToolButton id="NewButton" text="New" icon="pics/document-new.png"/>
+ <ToolButton id="EditButton" text="Edit" icon="pics/edit-rename.png"/>
+ <ToolButton id="DeleteButton" text="Delete" icon="pics/edit-delete.png"/>
+ <ToolButton id="DeleteButton2" text="Delete" icon="pics/edit-delete.png"/>
+ </HorizontalLayout>
+ <states>
+ <State name="ToolBar">
+ <SetProperty target="{MenuBarBackground}" property="y" value="180"/>
+ <SetProperty target="{MenuBarBackground}" property="height" value="62"/>
+ <SetProperty target="{MenuBar}" property="y" value="180"/>
+ <SetProperty target="{MenuBar}" property="height" value="60"/>
+ <SetProperty target="{ContextKeys}" property="opacity" value="0"/>
+ <SetProperty target="{ToolBar}" property="opacity" value="1"/>
+ </State>
+ </states>
+ <transitions>
+ <Transition fromState="*" toState="ToolBar" reversible="true">
+ <NumericAnimation properties="y,height,opacity" easing="easeInOutQuad" duration="250"/>
+ </Transition>
+ </transitions>
+ </FocusPanel>
+
+ </Item>
+
+ <CallMenu id="QuickMenu"/>
+
+</Item>
diff --git a/tests/benchmarks/qvariant/qvariant.pro b/tests/benchmarks/qvariant/qvariant.pro
index 68b4a97..63b5442 100644
--- a/tests/benchmarks/qvariant/qvariant.pro
+++ b/tests/benchmarks/qvariant/qvariant.pro
@@ -3,7 +3,6 @@ TEMPLATE = app
TARGET = tst_qvariant
DEPENDPATH += .
INCLUDEPATH += .
-QT -= gui
CONFIG += release
#CONFIG += debug
diff --git a/tests/benchmarks/qvariant/tst_qvariant.cpp b/tests/benchmarks/qvariant/tst_qvariant.cpp
index 4a7ad02..0eb1ae2 100644
--- a/tests/benchmarks/qvariant/tst_qvariant.cpp
+++ b/tests/benchmarks/qvariant/tst_qvariant.cpp
@@ -38,7 +38,9 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include <QtCore>
+#include <QtGui/QPixmap>
#include <qtest.h>
#define ITERATION_COUNT 1e5
@@ -47,64 +49,73 @@ class tst_qvariant : public QObject
{
Q_OBJECT
private slots:
+ void testBound();
+
void doubleVariantCreation();
void floatVariantCreation();
void rectVariantCreation();
void stringVariantCreation();
+ void pixmapVariantCreation();
+
void doubleVariantSetValue();
void floatVariantSetValue();
void rectVariantSetValue();
void stringVariantSetValue();
+
void doubleVariantAssignment();
void floatVariantAssignment();
void rectVariantAssignment();
void stringVariantAssignment();
};
-
-void tst_qvariant::doubleVariantCreation()
+void tst_qvariant::testBound()
{
- double d = 0;
+ qreal d = qreal(.5);
QBENCHMARK {
for(int i = 0; i < ITERATION_COUNT; ++i) {
- QVariant v(d);
+ d = qBound<qreal>(0, d, 1);
}
}
}
-void tst_qvariant::floatVariantCreation()
+template <typename T>
+static void variantCreation(T val)
{
- float f = 0;
QBENCHMARK {
for(int i = 0; i < ITERATION_COUNT; ++i) {
- QVariant v(f);
+ QVariant v(val);
}
}
}
+void tst_qvariant::doubleVariantCreation()
+{
+ variantCreation<double>(0.0);
+}
+
+void tst_qvariant::floatVariantCreation()
+{
+ variantCreation<float>(0.0f);
+}
+
void tst_qvariant::rectVariantCreation()
{
- QRect r(1,2,3,4);
- QBENCHMARK {
- for(int i = 0; i < ITERATION_COUNT; ++i) {
- QVariant v(r);
- }
- }
+ variantCreation<QRect>(QRect(1, 2, 3, 4));
}
void tst_qvariant::stringVariantCreation()
{
- QString s;
- QBENCHMARK {
- for(int i = 0; i < ITERATION_COUNT; ++i) {
- QVariant v(s);
- }
- }
+ variantCreation<QString>(QString());
}
-void tst_qvariant::doubleVariantSetValue()
+void tst_qvariant::pixmapVariantCreation()
+{
+ variantCreation<QPixmap>(QPixmap());
+}
+
+template <typename T>
+static void variantSetValue(T d)
{
- double d = 0;
QVariant v;
QBENCHMARK {
for(int i = 0; i < ITERATION_COUNT; ++i) {
@@ -113,42 +124,29 @@ void tst_qvariant::doubleVariantSetValue()
}
}
+void tst_qvariant::doubleVariantSetValue()
+{
+ variantSetValue<double>(0.0);
+}
+
void tst_qvariant::floatVariantSetValue()
{
- float f = 0;
- QVariant v;
- QBENCHMARK {
- for(int i = 0; i < ITERATION_COUNT; ++i) {
- qVariantSetValue(v, f);
- }
- }
+ variantSetValue<float>(0.0f);
}
void tst_qvariant::rectVariantSetValue()
{
- QRect r;
- QVariant v;
- QBENCHMARK {
- for(int i = 0; i < ITERATION_COUNT; ++i) {
- qVariantSetValue(v, r);
- }
- }
+ variantSetValue<QRect>(QRect());
}
void tst_qvariant::stringVariantSetValue()
{
- QString s;
- QVariant v;
- QBENCHMARK {
- for(int i = 0; i < ITERATION_COUNT; ++i) {
- qVariantSetValue(v, s);
- }
- }
+ variantSetValue<QString>(QString());
}
-void tst_qvariant::doubleVariantAssignment()
+template <typename T>
+static void variantAssignment(T d)
{
- double d = 0;
QVariant v;
QBENCHMARK {
for(int i = 0; i < ITERATION_COUNT; ++i) {
@@ -157,37 +155,24 @@ void tst_qvariant::doubleVariantAssignment()
}
}
+void tst_qvariant::doubleVariantAssignment()
+{
+ variantAssignment<double>(0.0);
+}
+
void tst_qvariant::floatVariantAssignment()
{
- float f = 0;
- QVariant v;
- QBENCHMARK {
- for(int i = 0; i < ITERATION_COUNT; ++i) {
- v = f;
- }
- }
+ variantAssignment<float>(0.0f);
}
void tst_qvariant::rectVariantAssignment()
{
- QRect r;
- QVariant v;
- QBENCHMARK {
- for(int i = 0; i < ITERATION_COUNT; ++i) {
- v = r;
- }
- }
+ variantAssignment<QRect>(QRect());
}
void tst_qvariant::stringVariantAssignment()
{
- QString s;
- QVariant v;
- QBENCHMARK {
- for(int i = 0; i < ITERATION_COUNT; ++i) {
- v = s;
- }
- }
+ variantAssignment<QString>(QString());
}
QTEST_MAIN(tst_qvariant)