From: Aaron Kennedy Date: Thu, 5 May 2011 05:24:17 +0000 (+1000) Subject: Compilation benchmark X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=1332e9277cf68b0232abf666cd0c27c39b766ef1;p=konrad%2Fqtdeclarative.git Compilation benchmark Change-Id: Iaa875817367d3a9600dd1ad685f996377af9f82d --- diff --git a/src/declarative/qml/parser/qdeclarativejsglobal_p.h b/src/declarative/qml/parser/qdeclarativejsglobal_p.h index 776937c..4fd8b84 100644 --- a/src/declarative/qml/parser/qdeclarativejsglobal_p.h +++ b/src/declarative/qml/parser/qdeclarativejsglobal_p.h @@ -58,7 +58,7 @@ #else // !QT_CREATOR # define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE # define QT_QML_END_NAMESPACE QT_END_NAMESPACE -# define QML_PARSER_EXPORT +# define QML_PARSER_EXPORT Q_AUTOTEST_EXPORT #endif // QT_CREATOR #endif // QDECLARATIVEJSGLOBAL_P_H diff --git a/src/declarative/qml/qdeclarativescriptparser_p.h b/src/declarative/qml/qdeclarativescriptparser_p.h index fd89f75..f8cea76 100644 --- a/src/declarative/qml/qdeclarativescriptparser_p.h +++ b/src/declarative/qml/qdeclarativescriptparser_p.h @@ -67,7 +67,7 @@ QT_MODULE(Declarative) class QByteArray; class QDeclarativeScriptParserJsASTData; -class QDeclarativeScriptParser +class Q_AUTOTEST_EXPORT QDeclarativeScriptParser { public: class Import diff --git a/tests/benchmarks/declarative/compilation/tst_compilation.cpp b/tests/benchmarks/declarative/compilation/tst_compilation.cpp index 7bf6c9d..e09b340 100644 --- a/tests/benchmarks/declarative/compilation/tst_compilation.cpp +++ b/tests/benchmarks/declarative/compilation/tst_compilation.cpp @@ -40,9 +40,18 @@ ****************************************************************************/ #include -#include -#include + +#include +#include +#include +#include +#include +#include +#include + #include +#include +#include #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -58,6 +67,12 @@ public: private slots: void boomblock(); + void jsparser_data(); + void jsparser(); + + void scriptparser_data(); + void scriptparser(); + private: QDeclarativeEngine engine; }; @@ -90,6 +105,61 @@ void tst_compilation::boomblock() } } +void tst_compilation::jsparser_data() +{ + QTest::addColumn("file"); + + QTest::newRow("boomblock") << QString(SRCDIR + QLatin1String("/data/BoomBlock.qml")); +} + +void tst_compilation::jsparser() +{ + QFETCH(QString, file); + + QFile f(file); + QVERIFY(f.open(QIODevice::ReadOnly)); + QByteArray data = f.readAll(); + + QTextStream stream(data, QIODevice::ReadOnly); + const QString code = stream.readAll(); + + QBENCHMARK { + QDeclarativeJS::Engine engine; + QDeclarativeJS::NodePool nodePool(file, &engine); + + QDeclarativeJS::Lexer lexer(&engine); + lexer.setCode(code, -1); + + QDeclarativeJS::Parser parser(&engine); + parser.parse(); + parser.ast(); + } +} + +void tst_compilation::scriptparser_data() +{ + QTest::addColumn("file"); + + QTest::newRow("boomblock") << QString(SRCDIR + QLatin1String("/data/BoomBlock.qml")); +} + +void tst_compilation::scriptparser() +{ + QFETCH(QString, file); + + QFile f(file); + QVERIFY(f.open(QIODevice::ReadOnly)); + QByteArray data = f.readAll(); + + QUrl url = QUrl::fromLocalFile(file); + + QBENCHMARK { + QDeclarativeScriptParser parser; + parser.parse(data, url); + parser.tree(); + } +} + QTEST_MAIN(tst_compilation) #include "tst_compilation.moc"