summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlcompiler.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-10-29 03:32:18 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-10-29 03:32:18 (GMT)
commite8bc4cebe9963a8a4534a5febbd606a6e4d6a332 (patch)
tree5ffea900d9b05a58c2a579ac6d1e041286108151 /src/declarative/qml/qmlcompiler.cpp
parent6c548e21f48b07d55187952ff21cbbc23fdd3927 (diff)
downloadQt-e8bc4cebe9963a8a4534a5febbd606a6e4d6a332.zip
Qt-e8bc4cebe9963a8a4534a5febbd606a6e4d6a332.tar.gz
Qt-e8bc4cebe9963a8a4534a5febbd606a6e4d6a332.tar.bz2
Simple compiler statistics
Diffstat (limited to 'src/declarative/qml/qmlcompiler.cpp')
-rw-r--r--src/declarative/qml/qmlcompiler.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 7a417bb..8f3d6a2 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -76,6 +76,7 @@
QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(compilerDump, QML_COMPILER_DUMP);
+DEFINE_BOOL_CONFIG_OPTION(compilerStatDump, QML_COMPILER_STATISTICS_DUMP);
using namespace QmlParser;
@@ -613,6 +614,8 @@ bool QmlCompiler::compile(QmlEngine *engine,
if (!isError()) {
if (compilerDump())
out->dumpInstructions();
+ if (compilerStatDump())
+ dumpStats();
} else {
reset(out);
}
@@ -664,6 +667,8 @@ void QmlCompiler::compileTree(Object *tree)
bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
{
+ componentStat.objects++;
+
Q_ASSERT (obj->type != -1);
const QmlCompiledData::TypeReference &tr =
output->types.at(obj->type);
@@ -1148,15 +1153,21 @@ bool QmlCompiler::buildComponentFromRoot(QmlParser::Object *obj,
const BindingContext &ctxt)
{
ComponentCompileState oldComponentCompileState = compileState;
+ ComponentStat oldComponentStat = componentStat;
+
compileState = ComponentCompileState();
compileState.root = obj;
+ componentStat = ComponentStat();
+ componentStat.lineNumber = obj->location.start.line;
+
if (obj)
COMPILE_CHECK(buildObject(obj, ctxt));
COMPILE_CHECK(completeComponentBuild());
compileState = oldComponentCompileState;
+ componentStat = oldComponentStat;
return true;
}
@@ -1646,6 +1657,7 @@ void QmlCompiler::saveComponentState()
Q_ASSERT(!savedCompileStates.contains(compileState.root));
savedCompileStates.insert(compileState.root, compileState);
+ savedComponentStats.append(componentStat);
}
QmlCompiler::ComponentCompileState
@@ -2454,6 +2466,8 @@ int QmlCompiler::genContextCache()
bool QmlCompiler::completeComponentBuild()
{
+ componentStat.ids = compileState.ids.count();
+
for (int ii = 0; ii < compileState.aliasingObjects.count(); ++ii) {
Object *aliasObject = compileState.aliasingObjects.at(ii);
COMPILE_CHECK(buildDynamicMeta(aliasObject, ResolveAliases));
@@ -2478,6 +2492,8 @@ bool QmlCompiler::completeComponentBuild()
QByteArray(bs.compileData(), bs.compileDataSize());
type = QmlExpressionPrivate::BasicScriptEngineData;
binding.isBasicScript = true;
+
+ componentStat.optimizedBindings++;
} else {
type = QmlExpressionPrivate::PreTransformedQtScriptData;
@@ -2495,6 +2511,8 @@ bool QmlCompiler::completeComponentBuild()
QByteArray((const char *)expression.constData(),
expression.length() * sizeof(QChar));
binding.isBasicScript = false;
+
+ componentStat.scriptBindings++;
}
binding.compiledData.prepend(QByteArray((const char *)&type,
sizeof(quint32)));
@@ -2505,6 +2523,19 @@ bool QmlCompiler::completeComponentBuild()
return true;
}
+void QmlCompiler::dumpStats()
+{
+ qWarning().nospace() << "QML Document: " << output->url.toString();
+ for (int ii = 0; ii < savedComponentStats.count(); ++ii) {
+ const ComponentStat &stat = savedComponentStats.at(ii);
+ qWarning().nospace() << " Component Line " << stat.lineNumber;
+ qWarning().nospace() << " Total Objects: " << stat.objects;
+ qWarning().nospace() << " IDs Used: " << stat.ids;
+ qWarning().nospace() << " Optimized Bindings: " << stat.optimizedBindings;
+ qWarning().nospace() << " QScript Bindings: " << stat.scriptBindings;
+ }
+}
+
/*!
Returns true if from can be assigned to a (QObject) property of type
to.