diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2009-11-25 14:16:35 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2009-11-25 15:17:32 (GMT) |
commit | 0fbf2304625cfe895f232b4c64a95bcf0584bd92 (patch) | |
tree | 97444c7aefc6e22b2ce5fa0f25d43482e01b22ea | |
parent | e58b0e2e562f1c5284ced8671d85df748a4a9639 (diff) | |
download | Qt-0fbf2304625cfe895f232b4c64a95bcf0584bd92.zip Qt-0fbf2304625cfe895f232b4c64a95bcf0584bd92.tar.gz Qt-0fbf2304625cfe895f232b4c64a95bcf0584bd92.tar.bz2 |
Introduce QFileInfo benchmark
Right now only a benchmark for the canonicalized path.
Reviewed-by: TrustMe
-rw-r--r-- | tests/benchmarks/benchmarks.pro | 1 | ||||
-rw-r--r-- | tests/benchmarks/qfileinfo/main.cpp | 81 | ||||
-rw-r--r-- | tests/benchmarks/qfileinfo/qfileinfo.pro | 12 |
3 files changed, 94 insertions, 0 deletions
diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index a63fb41..9170039 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -3,6 +3,7 @@ SUBDIRS = containers-associative \ containers-sequential \ qanimation \ qbytearray \ + qfileinfo \ qfile_vs_qnetworkaccessmanager \ qpainter \ qtestlib-simple events \ diff --git a/tests/benchmarks/qfileinfo/main.cpp b/tests/benchmarks/qfileinfo/main.cpp new file mode 100644 index 0000000..7950f58 --- /dev/null +++ b/tests/benchmarks/qfileinfo/main.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QDebug> +#include <qtest.h> +#include <QtTest/QtTest> +#include <QtCore/QCoreApplication> +#include <QtCore/QFileInfo> + + +class qfileinfo : public QObject +{ + Q_OBJECT +private slots: + void canonicalFileNamePerformance(); + + void initTestCase(); + void cleanupTestCase(); +public: + qfileinfo() : QObject() {}; +}; + +void qfileinfo::initTestCase() +{ +} + +void qfileinfo::cleanupTestCase() +{ +} + +void qfileinfo::canonicalFileNamePerformance() +{ + QBENCHMARK { + for (int i = 0; i < 5000; i++) { + // this actually calls canonicalFilePath twice, once inside QCoreApplication. + QFileInfo fi(QCoreApplication::applicationFilePath()); + fi.canonicalFilePath(); + } + } +} + +QTEST_MAIN(qfileinfo) + +#include "main.moc" diff --git a/tests/benchmarks/qfileinfo/qfileinfo.pro b/tests/benchmarks/qfileinfo/qfileinfo.pro new file mode 100644 index 0000000..295cb50 --- /dev/null +++ b/tests/benchmarks/qfileinfo/qfileinfo.pro @@ -0,0 +1,12 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = qfileinfo +DEPENDPATH += . +INCLUDEPATH += . + +QT -= gui + +CONFIG += release + +# Input +SOURCES += main.cpp |