summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/declarative/pointers/tst_pointers.cpp
blob: f397c0cc4774859ba779aebf47d78d276ab6cb5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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"