diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-08-21 07:23:33 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-08-21 07:23:33 (GMT) |
commit | 45357546c29240b95300f392084a2fe901073d85 (patch) | |
tree | aca89043c1bd80a3a7515402ee0fbb55b9cbf6ee /tests/benchmarks | |
parent | 2e645960930442e895f887f1ef5e226d14eabcc7 (diff) | |
parent | f11fc8f62558543dac1eca9d52a4801196c55221 (diff) | |
download | Qt-45357546c29240b95300f392084a2fe901073d85.zip Qt-45357546c29240b95300f392084a2fe901073d85.tar.gz Qt-45357546c29240b95300f392084a2fe901073d85.tar.bz2 |
Merge commit 'qt/master'
Conflicts:
configure.exe
examples/examples.pro
qmake/Makefile.unix
qmake/Makefile.win32
qmake/Makefile.win32-g++
qmake/Makefile.win32-g++-sh
qmake/qmake.pro
src/script/api/qscriptable.h
src/script/api/qscriptclasspropertyiterator.h
src/script/api/qscriptcontext.h
src/script/api/qscriptengineagent.cpp
src/script/api/qscriptstring.cpp
src/script/api/qscriptstring.h
src/script/api/qscriptvalueiterator.cpp
src/script/api/qscriptvalueiterator.h
src/script/qscriptclass.cpp
src/script/qscriptcontext.cpp
src/script/qscriptengine.cpp
src/script/qscriptengine_p.cpp
src/script/qscriptvalue.cpp
src/script/qscriptvalue_p.h
src/script/qscriptvalueimplfwd_p.h
src/script/script.pro
src/src.pro
tests/auto/auto.pro
tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp
tools/configure/configureapp.cpp
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp | 411 | ||||
-rw-r--r-- | tests/benchmarks/qscriptengine/tst_qscriptengine.cpp | 17 |
2 files changed, 428 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" diff --git a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp index 81dedfa..515285d 100644 --- a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp +++ b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp @@ -69,6 +69,7 @@ private slots: void pushAndPopContext(); void toStringHandle(); void castValueToQreal(); + void nativeCall(); }; tst_QScriptEngine::tst_QScriptEngine() @@ -225,5 +226,21 @@ void tst_QScriptEngine::castValueToQreal() } } +static QScriptValue native_function(QScriptContext *, QScriptEngine *) +{ + return 42; +} + +void tst_QScriptEngine::nativeCall() +{ + QScriptEngine eng; + eng.globalObject().setProperty("fun", eng.newFunction(native_function)); + QBENCHMARK{ + eng.evaluate("var w = 0; for (i = 0; i < 100000; ++i) {\n" + " w += fun() + fun(); w -= fun(); fun(); w -= fun(); }"); + } +} + + QTEST_MAIN(tst_QScriptEngine) #include "tst_qscriptengine.moc" |