diff options
-rw-r--r-- | tests/benchmarks/declarative/pointers/pointers.pro | 6 | ||||
-rw-r--r-- | tests/benchmarks/declarative/pointers/tst_pointers.cpp | 43 |
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" |