Compilation benchmark
Change-Id: Iaa875817367d3a9600dd1ad685f996377af9f82d
This commit is contained in:
parent
21521c2d28
commit
1332e9277c
|
@ -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
|
||||
|
|
|
@ -67,7 +67,7 @@ QT_MODULE(Declarative)
|
|||
class QByteArray;
|
||||
|
||||
class QDeclarativeScriptParserJsASTData;
|
||||
class QDeclarativeScriptParser
|
||||
class Q_AUTOTEST_EXPORT QDeclarativeScriptParser
|
||||
{
|
||||
public:
|
||||
class Import
|
||||
|
|
|
@ -40,9 +40,18 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <qtest.h>
|
||||
#include <QDeclarativeEngine>
|
||||
#include <QDeclarativeComponent>
|
||||
|
||||
#include <QtDeclarative/qdeclarativeengine.h>
|
||||
#include <QtDeclarative/qdeclarativecomponent.h>
|
||||
#include <QtDeclarative/private/qdeclarativejsengine_p.h>
|
||||
#include <QtDeclarative/private/qdeclarativejsnodepool_p.h>
|
||||
#include <QtDeclarative/private/qdeclarativejsparser_p.h>
|
||||
#include <QtDeclarative/private/qdeclarativejslexer_p.h>
|
||||
#include <QtDeclarative/private/qdeclarativescriptparser_p.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
#include <QTextStream>
|
||||
|
||||
#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<QString>("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<QString>("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"
|
||||
|
|
Loading…
Reference in New Issue