summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/declarative/pointers
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-09-01 05:33:36 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-09-01 05:33:36 (GMT)
commitb605570b93213b90554c3ca63982972e7e20d556 (patch)
tree60418ac16b62479a952d2604a25cb519ea2e4bdc /tests/benchmarks/declarative/pointers
parent5db9309f372b4aec16c2206fccde0c4c3e19fdc2 (diff)
downloadQt-b605570b93213b90554c3ca63982972e7e20d556.zip
Qt-b605570b93213b90554c3ca63982972e7e20d556.tar.gz
Qt-b605570b93213b90554c3ca63982972e7e20d556.tar.bz2
Benchmark QGuard and QWeakPointer.
Diffstat (limited to 'tests/benchmarks/declarative/pointers')
-rw-r--r--tests/benchmarks/declarative/pointers/pointers.pro6
-rw-r--r--tests/benchmarks/declarative/pointers/tst_pointers.cpp43
2 files changed, 49 insertions, 0 deletions
diff --git a/tests/benchmarks/declarative/pointers/pointers.pro b/tests/benchmarks/declarative/pointers/pointers.pro
new file mode 100644
index 0000000..fafdcd6
--- /dev/null
+++ b/tests/benchmarks/declarative/pointers/pointers.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_pointers
+
+SOURCES += tst_pointers.cpp
+
diff --git a/tests/benchmarks/declarative/pointers/tst_pointers.cpp b/tests/benchmarks/declarative/pointers/tst_pointers.cpp
new file mode 100644
index 0000000..f397c0c
--- /dev/null
+++ b/tests/benchmarks/declarative/pointers/tst_pointers.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include "private/qguard_p.h"
+#include <QWeakPointer>
+
+class tst_pointers : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_pointers() {}
+
+private slots:
+ void guard();
+ void weakPointer();
+};
+
+void tst_pointers::guard()
+{
+ QObject *obj = new QObject;
+ QBENCHMARK {
+ QGuard<QObject> guardedObject;
+ guardedObject = obj;
+ }
+}
+
+void tst_pointers::weakPointer()
+{
+ QObject *obj = new QObject;
+ QBENCHMARK {
+ QWeakPointer<QObject> guardedObject;
+ guardedObject = obj;
+ }
+}
+
+QTEST_MAIN(tst_pointers)
+#include "tst_pointers.moc"