diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-08-20 23:20:14 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-08-20 23:20:14 (GMT) |
commit | bb8ed752d728c458dab7bd9279c9040a1c137789 (patch) | |
tree | 16168717ae22f6770fbb6612b23a7a8e4b23e8bd /tests/benchmarks | |
parent | e90a5e819478b656963de0492a1b234c8863a12b (diff) | |
parent | a7b31fccbbbb4250e9cad709fe382fe16421b236 (diff) | |
download | Qt-bb8ed752d728c458dab7bd9279c9040a1c137789.zip Qt-bb8ed752d728c458dab7bd9279c9040a1c137789.tar.gz Qt-bb8ed752d728c458dab7bd9279c9040a1c137789.tar.bz2 |
Merge branch 'kinetic-transform' of git@scm.dev.nokia.troll.no:qt/kinetic
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp | 411 |
1 files changed, 411 insertions, 0 deletions
diff --git a/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp b/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp index aeefd20..f80a142 100644 --- a/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp +++ b/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp @@ -67,6 +67,33 @@ private slots: void mapVectorDirect_data(); void mapVectorDirect(); + + void compareTranslate_data(); + void compareTranslate(); + + void compareTranslateAfterScale_data(); + void compareTranslateAfterScale(); + + void compareTranslateAfterRotate_data(); + void compareTranslateAfterRotate(); + + void compareScale_data(); + void compareScale(); + + void compareScaleAfterTranslate_data(); + void compareScaleAfterTranslate(); + + void compareScaleAfterRotate_data(); + void compareScaleAfterRotate(); + + void compareRotate_data(); + void compareRotate(); + + void compareRotateAfterTranslate_data(); + void compareRotateAfterTranslate(); + + void compareRotateAfterScale_data(); + void compareRotateAfterScale(); }; static qreal const generalValues[16] = @@ -256,6 +283,390 @@ void tst_QMatrix4x4::mapVectorDirect() } } +// Compare the performance of QTransform::translate() to +// QMatrix4x4::translate(). +void tst_QMatrix4x4::compareTranslate_data() +{ + QTest::addColumn<bool>("useQTransform"); + QTest::addColumn<QVector3D>("translation"); + + QTest::newRow("QTransform::translate(0, 0, 0)") + << true << QVector3D(0, 0, 0); + QTest::newRow("QMatrix4x4::translate(0, 0, 0)") + << false << QVector3D(0, 0, 0); + + QTest::newRow("QTransform::translate(1, 2, 0)") + << true << QVector3D(1, 2, 0); + QTest::newRow("QMatrix4x4::translate(1, 2, 0)") + << false << QVector3D(1, 2, 0); + + QTest::newRow("QTransform::translate(1, 2, 4)") + << true << QVector3D(1, 2, 4); + QTest::newRow("QMatrix4x4::translate(1, 2, 4)") + << false << QVector3D(1, 2, 4); +} +void tst_QMatrix4x4::compareTranslate() +{ + QFETCH(bool, useQTransform); + QFETCH(QVector3D, translation); + + qreal x = translation.x(); + qreal y = translation.y(); + qreal z = translation.z(); + + if (useQTransform) { + QTransform t; + QBENCHMARK { + t.translate(x, y); + } + } else if (z == 0.0f) { + QMatrix4x4 m; + QBENCHMARK { + m.translate(x, y); + } + } else { + QMatrix4x4 m; + QBENCHMARK { + m.translate(x, y, z); + } + } +} + +// Compare the performance of QTransform::translate() to +// QMatrix4x4::translate() after priming the matrix with a scale(). +void tst_QMatrix4x4::compareTranslateAfterScale_data() +{ + compareTranslate_data(); +} +void tst_QMatrix4x4::compareTranslateAfterScale() +{ + QFETCH(bool, useQTransform); + QFETCH(QVector3D, translation); + + qreal x = translation.x(); + qreal y = translation.y(); + qreal z = translation.z(); + + if (useQTransform) { + QTransform t; + t.scale(3, 4); + QBENCHMARK { + t.translate(x, y); + } + } else if (z == 0.0f) { + QMatrix4x4 m; + m.scale(3, 4); + QBENCHMARK { + m.translate(x, y); + } + } else { + QMatrix4x4 m; + m.scale(3, 4, 5); + QBENCHMARK { + m.translate(x, y, z); + } + } +} + +// Compare the performance of QTransform::translate() to +// QMatrix4x4::translate() after priming the matrix with a rotate(). +void tst_QMatrix4x4::compareTranslateAfterRotate_data() +{ + compareTranslate_data(); +} +void tst_QMatrix4x4::compareTranslateAfterRotate() +{ + QFETCH(bool, useQTransform); + QFETCH(QVector3D, translation); + + qreal x = translation.x(); + qreal y = translation.y(); + qreal z = translation.z(); + + if (useQTransform) { + QTransform t; + t.rotate(45.0f); + QBENCHMARK { + t.translate(x, y); + } + } else if (z == 0.0f) { + QMatrix4x4 m; + m.rotate(45.0f, 0, 0, 1); + QBENCHMARK { + m.translate(x, y); + } + } else { + QMatrix4x4 m; + m.rotate(45.0f, 0, 0, 1); + QBENCHMARK { + m.translate(x, y, z); + } + } +} + +// Compare the performance of QTransform::scale() to +// QMatrix4x4::scale(). +void tst_QMatrix4x4::compareScale_data() +{ + QTest::addColumn<bool>("useQTransform"); + QTest::addColumn<QVector3D>("scale"); + + QTest::newRow("QTransform::scale(1, 1, 1)") + << true << QVector3D(1, 1, 1); + QTest::newRow("QMatrix4x4::scale(1, 1, 1)") + << false << QVector3D(1, 1, 1); + + QTest::newRow("QTransform::scale(3, 6, 1)") + << true << QVector3D(3, 6, 1); + QTest::newRow("QMatrix4x4::scale(3, 6, 1)") + << false << QVector3D(3, 6, 1); + + QTest::newRow("QTransform::scale(3, 6, 4)") + << true << QVector3D(3, 6, 4); + QTest::newRow("QMatrix4x4::scale(3, 6, 4)") + << false << QVector3D(3, 6, 4); +} +void tst_QMatrix4x4::compareScale() +{ + QFETCH(bool, useQTransform); + QFETCH(QVector3D, scale); + + qreal x = scale.x(); + qreal y = scale.y(); + qreal z = scale.z(); + + if (useQTransform) { + QTransform t; + QBENCHMARK { + t.scale(x, y); + } + } else if (z == 1.0f) { + QMatrix4x4 m; + QBENCHMARK { + m.scale(x, y); + } + } else { + QMatrix4x4 m; + QBENCHMARK { + m.scale(x, y, z); + } + } +} + +// Compare the performance of QTransform::scale() to +// QMatrix4x4::scale() after priming the matrix with a translate(). +void tst_QMatrix4x4::compareScaleAfterTranslate_data() +{ + compareScale_data(); +} +void tst_QMatrix4x4::compareScaleAfterTranslate() +{ + QFETCH(bool, useQTransform); + QFETCH(QVector3D, scale); + + qreal x = scale.x(); + qreal y = scale.y(); + qreal z = scale.z(); + + if (useQTransform) { + QTransform t; + t.translate(20, 34); + QBENCHMARK { + t.scale(x, y); + } + } else if (z == 1.0f) { + QMatrix4x4 m; + m.translate(20, 34); + QBENCHMARK { + m.scale(x, y); + } + } else { + QMatrix4x4 m; + m.translate(20, 34, 42); + QBENCHMARK { + m.scale(x, y, z); + } + } +} + +// Compare the performance of QTransform::scale() to +// QMatrix4x4::scale() after priming the matrix with a rotate(). +void tst_QMatrix4x4::compareScaleAfterRotate_data() +{ + compareScale_data(); +} +void tst_QMatrix4x4::compareScaleAfterRotate() +{ + QFETCH(bool, useQTransform); + QFETCH(QVector3D, scale); + + qreal x = scale.x(); + qreal y = scale.y(); + qreal z = scale.z(); + + if (useQTransform) { + QTransform t; + t.rotate(45.0f); + QBENCHMARK { + t.scale(x, y); + } + } else if (z == 1.0f) { + QMatrix4x4 m; + m.rotate(45.0f, 0, 0, 1); + QBENCHMARK { + m.scale(x, y); + } + } else { + QMatrix4x4 m; + m.rotate(45.0f, 0, 0, 1); + QBENCHMARK { + m.scale(x, y, z); + } + } +} + +// Compare the performance of QTransform::rotate() to +// QMatrix4x4::rotate(). +void tst_QMatrix4x4::compareRotate_data() +{ + QTest::addColumn<bool>("useQTransform"); + QTest::addColumn<qreal>("angle"); + QTest::addColumn<QVector3D>("rotation"); + QTest::addColumn<int>("axis"); + + QTest::newRow("QTransform::rotate(0, ZAxis)") + << true << qreal(0.0f) << QVector3D(0, 0, 1) << int(Qt::ZAxis); + QTest::newRow("QMatrix4x4::rotate(0, ZAxis)") + << false << qreal(0.0f) << QVector3D(0, 0, 1) << int(Qt::ZAxis); + + QTest::newRow("QTransform::rotate(45, ZAxis)") + << true << qreal(45.0f) << QVector3D(0, 0, 1) << int(Qt::ZAxis); + QTest::newRow("QMatrix4x4::rotate(45, ZAxis)") + << false << qreal(45.0f) << QVector3D(0, 0, 1) << int(Qt::ZAxis); + + QTest::newRow("QTransform::rotate(90, ZAxis)") + << true << qreal(90.0f) << QVector3D(0, 0, 1) << int(Qt::ZAxis); + QTest::newRow("QMatrix4x4::rotate(90, ZAxis)") + << false << qreal(90.0f) << QVector3D(0, 0, 1) << int(Qt::ZAxis); + + QTest::newRow("QTransform::rotate(0, YAxis)") + << true << qreal(0.0f) << QVector3D(0, 1, 0) << int(Qt::YAxis); + QTest::newRow("QMatrix4x4::rotate(0, YAxis)") + << false << qreal(0.0f) << QVector3D(0, 1, 0) << int(Qt::YAxis); + + QTest::newRow("QTransform::rotate(45, YAxis)") + << true << qreal(45.0f) << QVector3D(0, 1, 0) << int(Qt::YAxis); + QTest::newRow("QMatrix4x4::rotate(45, YAxis)") + << false << qreal(45.0f) << QVector3D(0, 1, 0) << int(Qt::YAxis); + + QTest::newRow("QTransform::rotate(90, YAxis)") + << true << qreal(90.0f) << QVector3D(0, 1, 0) << int(Qt::YAxis); + QTest::newRow("QMatrix4x4::rotate(90, YAxis)") + << false << qreal(90.0f) << QVector3D(0, 1, 0) << int(Qt::YAxis); + + QTest::newRow("QTransform::rotate(0, XAxis)") + << true << qreal(0.0f) << QVector3D(0, 1, 0) << int(Qt::XAxis); + QTest::newRow("QMatrix4x4::rotate(0, XAxis)") + << false << qreal(0.0f) << QVector3D(0, 1, 0) << int(Qt::XAxis); + + QTest::newRow("QTransform::rotate(45, XAxis)") + << true << qreal(45.0f) << QVector3D(1, 0, 0) << int(Qt::XAxis); + QTest::newRow("QMatrix4x4::rotate(45, XAxis)") + << false << qreal(45.0f) << QVector3D(1, 0, 0) << int(Qt::XAxis); + + QTest::newRow("QTransform::rotate(90, XAxis)") + << true << qreal(90.0f) << QVector3D(1, 0, 0) << int(Qt::XAxis); + QTest::newRow("QMatrix4x4::rotate(90, XAxis)") + << false << qreal(90.0f) << QVector3D(1, 0, 0) << int(Qt::XAxis); +} +void tst_QMatrix4x4::compareRotate() +{ + QFETCH(bool, useQTransform); + QFETCH(qreal, angle); + QFETCH(QVector3D, rotation); + QFETCH(int, axis); + + qreal x = rotation.x(); + qreal y = rotation.y(); + qreal z = rotation.z(); + + if (useQTransform) { + QTransform t; + QBENCHMARK { + t.rotate(angle, Qt::Axis(axis)); + } + } else { + QMatrix4x4 m; + QBENCHMARK { + m.rotate(angle, x, y, z); + } + } +} + +// Compare the performance of QTransform::rotate() to +// QMatrix4x4::rotate() after priming the matrix with a translate(). +void tst_QMatrix4x4::compareRotateAfterTranslate_data() +{ + compareRotate_data(); +} +void tst_QMatrix4x4::compareRotateAfterTranslate() +{ + QFETCH(bool, useQTransform); + QFETCH(qreal, angle); + QFETCH(QVector3D, rotation); + QFETCH(int, axis); + + qreal x = rotation.x(); + qreal y = rotation.y(); + qreal z = rotation.z(); + + if (useQTransform) { + QTransform t; + t.translate(3, 4); + QBENCHMARK { + t.rotate(angle, Qt::Axis(axis)); + } + } else { + QMatrix4x4 m; + m.translate(3, 4, 5); + QBENCHMARK { + m.rotate(angle, x, y, z); + } + } +} + +// Compare the performance of QTransform::rotate() to +// QMatrix4x4::rotate() after priming the matrix with a scale(). +void tst_QMatrix4x4::compareRotateAfterScale_data() +{ + compareRotate_data(); +} +void tst_QMatrix4x4::compareRotateAfterScale() +{ + QFETCH(bool, useQTransform); + QFETCH(qreal, angle); + QFETCH(QVector3D, rotation); + QFETCH(int, axis); + + qreal x = rotation.x(); + qreal y = rotation.y(); + qreal z = rotation.z(); + + if (useQTransform) { + QTransform t; + t.scale(3, 4); + QBENCHMARK { + t.rotate(angle, Qt::Axis(axis)); + } + } else { + QMatrix4x4 m; + m.scale(3, 4, 5); + QBENCHMARK { + m.rotate(angle, x, y, z); + } + } +} + QTEST_MAIN(tst_QMatrix4x4) #include "tst_qmatrix4x4.moc" |