diff options
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/benchmarks.pro | 4 | ||||
-rw-r--r-- | tests/benchmarks/matrix_properties/data/CustomObject.qml | 46 | ||||
-rw-r--r-- | tests/benchmarks/matrix_properties/data/matrix_component.qml | 171 | ||||
-rw-r--r-- | tests/benchmarks/matrix_properties/matrix_properties.pro | 18 | ||||
-rw-r--r-- | tests/benchmarks/matrix_properties/tst_matrix_properties.cpp | 183 | ||||
-rw-r--r-- | tests/benchmarks/qarray/qarray.pro | 5 | ||||
-rw-r--r-- | tests/benchmarks/qarray/tst_qarray.cpp | 503 | ||||
-rw-r--r-- | tests/benchmarks/qglbuilder_perf/qglbuilder_perf.pro | 6 | ||||
-rw-r--r-- | tests/benchmarks/qglbuilder_perf/tst_qglbuilder_perf.cpp | 245 |
9 files changed, 0 insertions, 1181 deletions
diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro deleted file mode 100644 index 6c00e7ae..00000000 --- a/tests/benchmarks/benchmarks.pro +++ /dev/null @@ -1,4 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = qarray \ - qglbuilder_perf -contains(QT_CONFIG, declarative):SUBDIRS += matrix_properties diff --git a/tests/benchmarks/matrix_properties/data/CustomObject.qml b/tests/benchmarks/matrix_properties/data/CustomObject.qml deleted file mode 100644 index 1fa2c474..00000000 --- a/tests/benchmarks/matrix_properties/data/CustomObject.qml +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 - -QtObject { - property variant variantProp: 0 -} diff --git a/tests/benchmarks/matrix_properties/data/matrix_component.qml b/tests/benchmarks/matrix_properties/data/matrix_component.qml deleted file mode 100644 index 4611ca1b..00000000 --- a/tests/benchmarks/matrix_properties/data/matrix_component.qml +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 -import Qt3D 1.0 - -Item { - CustomObject { id: theObject } - property real scaleX : 1.0 - property real scaleY : 1.0 - property real scaleZ : 1.0 - property real translationX : 1.0 - property real translationY : 1.0 - property real translationZ : 1.0 - property real unboundReal : 1.0 - - property real variableBoundToMatrix : 1.0 - property real variableBoundToVariantList : 1.0 - - property variant matrixWithBoundVariable : Qt3D.matrix4x4 ( - 1.0, 0.0, 0.0, variableBoundToMatrix, - 0.0, 1.0, 0.0, 1.0, - 0.0, 0.0, 1.0, 1.0, - 0.0, 0.0, 0.0, 1.0 ); - - property variant variantListWithBoundVariable : [ - 1.0, 0.0, 0.0, variableBoundToVariantList, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0 ]; - - - function createMatrix4x4WithConstants() - { - theObject.variantProp = 0; - for (var i = 0; i < 1000; ++i) - theObject.variantProp = Qt3d.matrix4x4( - 1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0 ); - } - - function createOneMatrix4x4WithConstants() - { - theObject.variantProp = 0; - theObject.variantProp = Qt3d.matrix4x4( - 1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0 ); - } - - function createMatrix4x4WithVariables() - { - theObject.variantProp = 0; - for (var i = 0; i < 1000; ++i) - theObject.variantProp = Qt3d.matrix4x4 ( - scaleX, 0.0, 0.0, translationX, - 0.0, scaleY, 0.0, translationY, - 0.0, 0.0, scaleY, translationZ, - 0.0, 0.0, 0.0, 1.0 ); - } - - function createOneMatrix4x4WithVariables() - { - theObject.variantProp = 0; - theObject.variantProp = Qt3d.matrix4x4 ( - scaleX, 0.0, 0.0, translationX, - 0.0, scaleY, 0.0, translationY, - 0.0, 0.0, scaleY, translationZ, - 0.0, 0.0, 0.0, 1.0 ); - } - - function createVariantListWithConstants() - { - theObject.variantProp = 0; - for (var i = 0; i < 1000; ++i) - theObject.variantProp = [ - 1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0 ]; - } - - function createOneVariantListWithConstants() - { - theObject.variantProp = 0; - theObject.variantProp = [ - 1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0 ]; - } - - function createVariantListWithVariables() { - theObject.variantProp = 0; - for (var i = 0; i < 1000; ++i) - theObject.variantProp = [ - scalex, 0.0, 0.0, translationX, - 0.0, scaley, 0.0, translationY, - 0.0, 0.0, scalez, translationZ, - 0.0, 0.0, 0.0, 1.0 ]; - } - - function createOneVariantListWithVariables() { - theObject.variantProp = 0; - theObject.variantProp = [ - scalex, 0.0, 0.0, translationX, - 0.0, scaley, 0.0, translationY, - 0.0, 0.0, scalez, translationZ, - 0.0, 0.0, 0.0, 1.0 ]; - } - - function modifyMatrix4x4() { - for (var i = 0; i < 1000; ++i) - theObject.variantProp.m(2,3) = 1.0; - } - - function modifyVariantList() { - for (var i = 0; i < 1000; ++i) - theObject.variantProp[4] = 2.0; - } - - function modifyBoundVariable() { - translationX += 0.1; - } - - function modifyUnboundVariable() { - unboundReal += 0.1; - } - -} diff --git a/tests/benchmarks/matrix_properties/matrix_properties.pro b/tests/benchmarks/matrix_properties/matrix_properties.pro deleted file mode 100644 index ac490f37..00000000 --- a/tests/benchmarks/matrix_properties/matrix_properties.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = app -TARGET = tst_matrix_properties -QT += declarative script testlib -macx:CONFIG -= app_bundle - -SOURCES += tst_matrix_properties.cpp - -symbian* { - data.sources = data/* - data.path = data - DEPLOYMENT += data -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} - - - - diff --git a/tests/benchmarks/matrix_properties/tst_matrix_properties.cpp b/tests/benchmarks/matrix_properties/tst_matrix_properties.cpp deleted file mode 100644 index 98f4983b..00000000 --- a/tests/benchmarks/matrix_properties/tst_matrix_properties.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtTest/QtTest> -#include <QDeclarativeEngine> -#include <QDeclarativeComponent> - -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -// Application private dir is default search path for files, so SRCDIR can be set to empty -#define SRCDIR "." -#endif - -class tst_matrix_properties : public QObject -{ - Q_OBJECT -public: - tst_matrix_properties() {} - -private slots: - void initTestCase(); - - void create_data(); - void create(); - - void modify_data(); - void modify(); - - void boundVariableChange_data(); - void boundVariableChange(); - -// TODO: -// void assign(); - -private: -}; - -inline QUrl TEST_FILE(const char *filename) -{ - return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + QLatin1String(filename)); -} - -void tst_matrix_properties::initTestCase() -{ -} - -void tst_matrix_properties::create_data() -{ - QTest::addColumn<QString>("methodName"); - QTest::newRow("createMatrix4x4WithConstants") << "createMatrix4x4WithConstants()"; - QTest::newRow("createMatrix4x4WithVariables") << "createMatrix4x4WithVariables()"; - QTest::newRow("createVariantListWithConstants") << "createVariantListWithConstants()"; - QTest::newRow("createVariantListWithVariables") << "createVariantListWithVariables()"; -} - -void tst_matrix_properties::create() -{ - QFETCH(QString, methodName); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("matrix_component.qml")); - QObject *item = component.create(); - - QVERIFY(item != 0); - - int index = item->metaObject()->indexOfMethod(methodName.toUtf8().constData()); - QVERIFY(index != -1); - QMetaMethod method = item->metaObject()->method(index); - - QBENCHMARK { - method.invoke(item, Qt::DirectConnection); - } - - delete item; -} - -void tst_matrix_properties::modify_data() -{ - QTest::addColumn<QString>("initMethodName"); - QTest::addColumn<QString>("methodName"); - QTest::newRow("modifyMatrix4x4") << "createOneMatrix4x4WithConstants()" - << "modifyMatrix4x4()"; - QTest::newRow("modifyVariantList") << "createOneVariantListWithConstants()" - << "modifyVariantList()"; -} - -void tst_matrix_properties::modify() -{ - QFETCH(QString, initMethodName); - QFETCH(QString, methodName); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("matrix_component.qml")); - QObject *item = component.create(); - - QVERIFY(item != 0); - - // Set the test property to a matrix or variantlist as appropriate. - int index = item->metaObject()->indexOfMethod(initMethodName.toUtf8().constData()); - QVERIFY(index != -1); - QMetaMethod method = item->metaObject()->method(index); - method.invoke(item, Qt::DirectConnection); - - index = item->metaObject()->indexOfMethod(methodName.toUtf8().constData()); - QVERIFY(index != -1); - method = item->metaObject()->method(index); - - QBENCHMARK { - method.invoke(item, Qt::DirectConnection); - } - - delete item; -} - -void tst_matrix_properties::boundVariableChange_data() -{ - QTest::addColumn<QString>("propertyName"); - QTest::newRow("UnboundVariable") - << "unboundReal"; - QTest::newRow("BoundOnMatrix") - << "variableBoundToMatrix"; - QTest::newRow("BoundOnVariantList") - << "variableBoundToVariantList"; -} - -void tst_matrix_properties::boundVariableChange() -{ - QFETCH(QString, propertyName); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("matrix_component.qml")); - QObject *item = component.create(); - - QVERIFY(item != 0); - - QByteArray propertyNameByteArray = propertyName.toUtf8().constData(); - qreal value = 1.0; - - QBENCHMARK { - item->setProperty(propertyNameByteArray.constData(), (value += 0.1)); - } - - delete item; -} - -QTEST_MAIN(tst_matrix_properties) - -#include "tst_matrix_properties.moc" diff --git a/tests/benchmarks/qarray/qarray.pro b/tests/benchmarks/qarray/qarray.pro deleted file mode 100644 index c237dde4..00000000 --- a/tests/benchmarks/qarray/qarray.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE=app -QT += testlib -CONFIG += unittest warn_on qt3d - -SOURCES += tst_qarray.cpp diff --git a/tests/benchmarks/qarray/tst_qarray.cpp b/tests/benchmarks/qarray/tst_qarray.cpp deleted file mode 100644 index a304eae6..00000000 --- a/tests/benchmarks/qarray/tst_qarray.cpp +++ /dev/null @@ -1,503 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtTest/QtTest> -#include <QtGui/qvector3d.h> -#include <QtCore/qvarlengtharray.h> -#include <QtCore/qvector.h> -#include <QtCore/qlist.h> -#include "qarray.h" -#ifndef QT_NO_STL -#include <vector> -#endif - -//#define TEST_QLIST 1 - -class tst_QArray : public QObject -{ - Q_OBJECT -public: - tst_QArray() {} - virtual ~tst_QArray() {} - -private slots: - void append_data(); - void append(); - void appendReserved_data(); - void appendReserved(); - void appendVector3D_data(); - void appendVector3D(); - void appendSmall_data(); - void appendSmall(); - void appendFourAtATime_data(); - void appendFourAtATime(); - void clear_data(); - void clear(); - void randomAccess_data(); - void randomAccess(); -}; - -enum { - Test_Vector, - Test_List, - Test_VarLengthArray, - Test_Array, - Test_STLVector -}; - -void tst_QArray::append_data() -{ - QTest::addColumn<int>("size"); - QTest::addColumn<int>("type"); - - QByteArray name; - for (int size = 0; size < 1024; size += 12) { - name = "QVector--"; - name += QByteArray::number(size); - QTest::newRow(name.constData()) << size << int(Test_Vector); - -#if TEST_QLIST - name = "QList--"; - name += QByteArray::number(size); - QTest::newRow(name.constData()) << size << int(Test_List); -#endif - - name = "QVarLengthArray--"; - name += QByteArray::number(size); - QTest::newRow(name.constData()) << size << int(Test_VarLengthArray); - - name = "QArray--"; - name += QByteArray::number(size); - QTest::newRow(name.constData()) << size << int(Test_Array); - -#ifndef QT_NO_STL - name = "std::vector--"; - name += QByteArray::number(size); - QTest::newRow(name.constData()) << size << int(Test_STLVector); -#endif - } -} - -void tst_QArray::append() -{ - QFETCH(int, size); - QFETCH(int, type); - - if (type == Test_Vector) { - QVector<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - } - } else if (type == Test_List) { - QList<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - } - } else if (type == Test_VarLengthArray) { - QVarLengthArray<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - } - } else if (type == Test_Array) { - QArray<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - } -#ifndef QT_NO_STL - } else if (type == Test_STLVector) { - std::vector<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.push_back(float(i)); - } -#endif - } -} - -void tst_QArray::appendReserved_data() -{ - append_data(); -} - -void tst_QArray::appendReserved() -{ - QFETCH(int, size); - QFETCH(int, type); - - if (type == Test_Vector) { - QVector<float> buffer; - buffer.reserve(size); - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - } - } else if (type == Test_List) { - QList<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - } - } else if (type == Test_VarLengthArray) { - QVarLengthArray<float> buffer; - buffer.reserve(size); - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - } - } else if (type == Test_Array) { - QArray<float> buffer; - buffer.reserve(size); - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - } -#ifndef QT_NO_STL - } else if (type == Test_STLVector) { - std::vector<float> buffer; - buffer.reserve(size); - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.push_back(float(i)); - } -#endif - } -} - -void tst_QArray::appendVector3D_data() -{ - append_data(); -} - -void tst_QArray::appendVector3D() -{ - QFETCH(int, size); - QFETCH(int, type); - - if (type == Test_Vector) { - QVector<QVector3D> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(QVector3D(i, i + 1, i + 2)); - } - } else if (type == Test_List) { - QList<QVector3D> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(QVector3D(i, i + 1, i + 2)); - } - } else if (type == Test_VarLengthArray) { - QVarLengthArray<QVector3D> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(QVector3D(i, i + 1, i + 2)); - } - } else if (type == Test_Array) { - QArray<QVector3D> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(QVector3D(i, i + 1, i + 2)); - } -#ifndef QT_NO_STL - } else if (type == Test_STLVector) { - std::vector<QVector3D> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.push_back(QVector3D(i, i + 1, i + 2)); - } -#endif - } -} - -void tst_QArray::appendSmall_data() -{ - QTest::addColumn<int>("size"); - QTest::addColumn<int>("type"); - - QByteArray name; - for (int size = 0; size < 16; ++size) { - name = "QVector--"; - name += QByteArray::number(size); - QTest::newRow(name.constData()) << size << int(Test_Vector); - -#if TEST_QLIST - name = "QList--"; - name += QByteArray::number(size); - QTest::newRow(name.constData()) << size << int(Test_List); -#endif - - name = "QVarLengthArray--"; - name += QByteArray::number(size); - QTest::newRow(name.constData()) << size << int(Test_VarLengthArray); - - name = "QArray--"; - name += QByteArray::number(size); - QTest::newRow(name.constData()) << size << int(Test_Array); - -#ifndef QT_NO_STL - name = "std::vector--"; - name += QByteArray::number(size); - QTest::newRow(name.constData()) << size << int(Test_STLVector); -#endif - } -} - -void tst_QArray::appendSmall() -{ - append(); -} - -void tst_QArray::appendFourAtATime_data() -{ - append_data(); -} - -void tst_QArray::appendFourAtATime() -{ - QFETCH(int, size); - QFETCH(int, type); - - if (type == Test_Vector) { - QVector<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; i += 4) { - buffer.append(float(i)); - buffer.append(float(i + 1)); - buffer.append(float(i + 2)); - buffer.append(float(i + 3)); - } - } - } else if (type == Test_List) { - QList<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; i += 4) { - buffer.append(float(i)); - buffer.append(float(i + 1)); - buffer.append(float(i + 2)); - buffer.append(float(i + 3)); - } - } - } else if (type == Test_VarLengthArray) { - QVarLengthArray<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; i += 4) { - buffer.append(float(i)); - buffer.append(float(i + 1)); - buffer.append(float(i + 2)); - buffer.append(float(i + 3)); - } - } - } else if (type == Test_Array) { - QArray<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; i += 4) { - buffer.append(float(i), float(i + 1), - float(i + 2), float(i + 3)); - } - } -#ifndef QT_NO_STL - } else if (type == Test_STLVector) { - std::vector<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; i += 4) { - buffer.push_back(float(i)); - buffer.push_back(float(i + 1)); - buffer.push_back(float(i + 2)); - buffer.push_back(float(i + 3)); - } - } -#endif - } -} - -void tst_QArray::clear_data() -{ - append_data(); -} - -void tst_QArray::clear() -{ - QFETCH(int, size); - QFETCH(int, type); - - if (type == Test_Vector) { - QVector<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - buffer.clear(); - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - } - } else if (type == Test_List) { - QList<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - buffer.clear(); - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - } - } else if (type == Test_VarLengthArray) { - QVarLengthArray<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - buffer.clear(); - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - } - } else if (type == Test_Array) { - QArray<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - buffer.resize(0); - for (int i = 0; i < size; ++i) - buffer.append(float(i)); - } -#ifndef QT_NO_STL - } else if (type == Test_STLVector) { - std::vector<float> buffer; - QBENCHMARK { - for (int i = 0; i < size; ++i) - buffer.push_back(float(i)); - buffer.clear(); - for (int i = 0; i < size; ++i) - buffer.push_back(float(i)); - } -#endif - } -} - -void tst_QArray::randomAccess_data() -{ - QTest::addColumn<int>("type"); - - QTest::newRow("QVector") << int(Test_Vector); -#if TEST_QLIST - QTest::newRow("QList") << int(Test_List); -#endif - QTest::newRow("QVarLengthArray") << int(Test_VarLengthArray); - QTest::newRow("QArray") << int(Test_Array); -#ifndef QT_NO_STL - QTest::newRow("std::vector") << int(Test_STLVector); -#endif -} - -// To force the values below to be computed and stored. -static int volatile finalSum; - -void tst_QArray::randomAccess() -{ - QFETCH(int, type); - - if (type == Test_Vector) { - QVector<int> buffer; - for (int i = 0; i < 10000; ++i) - buffer.append(i); - QBENCHMARK { - for (int i = 10; i < 10000; ++i) - buffer[i] = buffer.at(i - 10) + buffer.at(i - 4) * 2; - int sum = 0; - for (int i = 0; i < 10000; ++i) - sum += buffer.at(i); - finalSum = sum; - } - } else if (type == Test_List) { - QList<int> buffer; - for (int i = 0; i < 10000; ++i) - buffer.append(i); - QBENCHMARK { - for (int i = 10; i < 10000; ++i) - buffer[i] = buffer[i - 10] + buffer[i - 4] * 2; - int sum = 0; - for (int i = 0; i < 10000; ++i) - sum += buffer[i]; - finalSum = sum; - } - } else if (type == Test_VarLengthArray) { - QVarLengthArray<int> buffer; - for (int i = 0; i < 10000; ++i) - buffer.append(i); - QBENCHMARK { - for (int i = 10; i < 10000; ++i) - buffer[i] = buffer[i - 10] + buffer[i - 4] * 2; - int sum = 0; - for (int i = 0; i < 10000; ++i) - sum += buffer[i]; - finalSum = sum; - } - } else if (type == Test_Array) { - QArray<int> buffer; - for (int i = 0; i < 10000; ++i) - buffer.append(i); - QBENCHMARK { - for (int i = 10; i < 10000; ++i) - buffer[i] = buffer.at(i - 10) + buffer.at(i - 4) * 2; - int sum = 0; - for (int i = 0; i < 10000; ++i) - sum += buffer.at(i); - finalSum = sum; - } -#ifndef QT_NO_STL - } else if (type == Test_STLVector) { - std::vector<int> buffer; - for (int i = 0; i < 10000; ++i) - buffer.push_back(i); - QBENCHMARK { - for (int i = 10; i < 10000; ++i) - buffer[i] = buffer[i - 10] + buffer[i - 4] * 2; - int sum = 0; - for (int i = 0; i < 10000; ++i) - sum += buffer[i]; - finalSum = sum; - } -#endif - } -} - -QTEST_MAIN(tst_QArray) - -#include "tst_qarray.moc" diff --git a/tests/benchmarks/qglbuilder_perf/qglbuilder_perf.pro b/tests/benchmarks/qglbuilder_perf/qglbuilder_perf.pro deleted file mode 100644 index 6f13bc09..00000000 --- a/tests/benchmarks/qglbuilder_perf/qglbuilder_perf.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE=app -QT += testlib -CONFIG += unittest warn_on qt3d - -SOURCES += tst_qglbuilder_perf.cpp -INCLUDEPATH += ../../../src/threed/geometry diff --git a/tests/benchmarks/qglbuilder_perf/tst_qglbuilder_perf.cpp b/tests/benchmarks/qglbuilder_perf/tst_qglbuilder_perf.cpp deleted file mode 100644 index 4667297a..00000000 --- a/tests/benchmarks/qglbuilder_perf/tst_qglbuilder_perf.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <ctime> -#include <QtTest/QtTest> -#include "qglbuilder.h" -#include "qglteapot.h" -#include "qglsection_p.h" -#include "qgeometrydata.h" - -class TestBuilder : public QGLBuilder -{ -public: - QGLSection *section() { return currentSection(); } - void setDefThreshold(int t) { setDefaultThreshold(t); } -}; - -class tst_QGLBuilder : public QObject -{ - Q_OBJECT -public: - tst_QGLBuilder() {} - virtual ~tst_QGLBuilder() {} - void addQuadBenchMarks(const QVector3DArray &data, int type); - -private slots: - void addQuadRandom_data(); - void addQuadRandom(); - void addQuadOrdered_data(); - void addQuadOrdered(); - void teapot(); -}; - -enum { - Test_3, - Test_7, - Test_10, - Test_20 -}; - -void tst_QGLBuilder::addQuadRandom_data() -{ - QTest::addColumn<int>("size"); - QTest::addColumn<int>("type"); - - QByteArray name; - for (int size = 10; size < 10000; size += 10) - { - name = "T3--"; - name += QByteArray::number(size); - QTest::newRow(name.constData()) << size << int(Test_3); - - name = "T7--"; - name += QByteArray::number(size); - QTest::newRow(name.constData()) << size << int(Test_7); - - name = "T10--"; - name += QByteArray::number(size); - QTest::newRow(name.constData()) << size << int(Test_10); - - name = "T20--"; - name += QByteArray::number(size); - QTest::newRow(name.constData()) << size << int(Test_20); - } -} - -static inline qreal randCoord() -{ - return (200.0f * ((qreal)qrand() / (qreal)RAND_MAX)) - 100.0f; -} - -QVector3D randVector() -{ - static bool seeded = false; - if (!seeded) - { - qsrand(time(0)); - seeded = true; - } - return QVector3D(randCoord(), randCoord(), randCoord()); -} - -void tst_QGLBuilder::addQuadRandom() -{ - QFETCH(int, size); - QFETCH(int, type); - - int n = qSqrt(size); - size = n * n; - QVector3DArray data; - data.reserve(size); - for (int i = 0; i < size; ++i) - { - // make sure (in face of randomness) we get a planar quad - QVector3D origin = randVector(); - QVector3D a; - while (a.isNull()) - a = randVector(); - QVector3D b; - while (b.isNull()) - b = randVector(); - data.append(origin, a, a+b, b); - } - addQuadBenchMarks(data, type); -} - -void tst_QGLBuilder::addQuadBenchMarks(const QVector3DArray &data, int type) -{ - int size = data.size(); - if (type == Test_3) - { - QBENCHMARK { - TestBuilder builder; - builder.newSection(QGL::Smooth); - builder.section()->setMapThreshold(3); - for (int i = 0; (i+3) < size; i += 4) - { - QGeometryData op; - op.appendVertex(data[i], data[i+1], data[i+2], data[i+3]); - builder.addQuads(op); - } - builder.finalizedSceneNode(); - } - } - else if (type == Test_7) - { - QBENCHMARK { - TestBuilder builder; - builder.newSection(QGL::Smooth); - builder.section()->setMapThreshold(7); - for (int i = 0; (i+3) < size; i += 4) - { - QGeometryData op; - op.appendVertex(data[i], data[i+1], data[i+2], data[i+3]); - builder.addQuads(op); - } - builder.finalizedSceneNode(); - } - } - else if (type == Test_10) - { - QBENCHMARK { - TestBuilder builder; - builder.newSection(QGL::Smooth); - builder.section()->setMapThreshold(10); - for (int i = 0; (i+3) < size; i += 4) - { - QGeometryData op; - op.appendVertex(data[i], data[i+1], data[i+2], data[i+3]); - builder.addQuads(op); - } - builder.finalizedSceneNode(); - } - } - else if (type == Test_20) - { - QBENCHMARK { - TestBuilder builder; - builder.newSection(QGL::Smooth); - builder.section()->setMapThreshold(20); - for (int i = 0; (i+3) < size; i += 4) - { - QGeometryData op; - op.appendVertex(data[i], data[i+1], data[i+2], data[i+3]); - builder.addQuads(op); - } - builder.finalizedSceneNode(); - } - } -} - -void tst_QGLBuilder::addQuadOrdered_data() -{ - addQuadRandom_data(); -} - -void tst_QGLBuilder::addQuadOrdered() -{ - QFETCH(int, size); - QFETCH(int, type); - - int n = qSqrt(size); - size = n * n; - QVector3DArray data; - data.reserve(size); - for (int i = 0; i < n; ++i) - for (int j = 0; j < n; ++j) - data.append(QVector3D(1.0f * i, 1.0f * j, 0.0f), - QVector3D(1.0f * (i+1), 1.0f * j, 0.0f), - QVector3D(1.0f * (i+1), 1.0f * (j+1), 0.0f), - QVector3D(1.0f * i, 1.0f * (j+1), 0.0f)); - addQuadBenchMarks(data, type); -} - -void tst_QGLBuilder::teapot() -{ - QBENCHMARK { - QGLBuilder builder; - builder << QGLTeapot(); - builder.finalizedSceneNode(); - } -} - - -QTEST_MAIN(tst_QGLBuilder) - -#include "tst_qglbuilder_perf.moc" |