summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-08-11 12:47:28 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-08-24 19:24:20 +0000
commit6d5caee804ca80eb81c364624847f70e62caa92e (patch)
tree8256be366f5def91c541fc9a525c9baa02a40f84 /src
parent9dd496c069154ac655be9b85b72a6eb409bfa223 (diff)
downloadqtdeclarative-6d5caee804ca80eb81c364624847f70e62caa92e.tar.gz
qtdeclarative-6d5caee804ca80eb81c364624847f70e62caa92e.tar.bz2
qtdeclarative-6d5caee804ca80eb81c364624847f70e62caa92e.zip
Fix profiling of QML/JS compilation
The compilation of .js resources was missed and the compile times were underestimated because the dependency resolution and error checking wasn't factored in. In particular we only profiled the done() step for QQmlTypeData. However, JavaScript compilation also occurs in the dataReceived() step of QQmlScriptBlob and QQmlTypeData will already parse the program into an AST at that step. Compile steps can be nested now, but considering the fact that significant time may be spent before and after compiling dependencies for a parent module, this seems to be the best way to model them. Furthermore, in order to not needlessly convert QUrl to QString at runtime, the compilation profiler saves the files now as QUrl. Change-Id: I215a87787f9117c069ecd77b2d913cc0b0ff3c89 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp2
-rw-r--r--src/qml/debugger/qqmlprofiler_p.h11
-rw-r--r--src/qml/qml/qqmltypeloader.cpp8
3 files changed, 13 insertions, 8 deletions
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp
index 349c181d1..245900aba 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp
@@ -81,7 +81,7 @@ static void qQmlProfilerDataToByteArrays(const QQmlProfilerData *d, QList<QByteA
ds << QQmlProfilerDefinitions::QmlBinding;
break;
case QQmlProfilerDefinitions::RangeData:
- ds << d->detailString;
+ ds << (d->detailString.isEmpty() ? d->detailUrl.toString() : d->detailString);
break;
case QQmlProfilerDefinitions::RangeLocation:
ds << (d->detailUrl.isEmpty() ? d->detailString : d->detailUrl.toString()) << d->x
diff --git a/src/qml/debugger/qqmlprofiler_p.h b/src/qml/debugger/qqmlprofiler_p.h
index 3c8337c96..7e29c3ede 100644
--- a/src/qml/debugger/qqmlprofiler_p.h
+++ b/src/qml/debugger/qqmlprofiler_p.h
@@ -99,8 +99,9 @@ struct Q_AUTOTEST_EXPORT QQmlProfilerData
int messageType; //bit field of QQmlProfilerService::Message
int detailType;
+ // RangeData prefers detailString; RangeLocation prefers detailUrl.
QString detailString; //used by RangeData and possibly by RangeLocation
- QUrl detailUrl; //used by RangeLocation, overrides detailString
+ QUrl detailUrl; //used by RangeLocation and possibly by RangeData
int x; //used by RangeLocation
int y; //used by RangeLocation
@@ -120,11 +121,11 @@ public:
// Have toByteArrays() construct another RangeData event from the same QString later.
// This is somewhat pointless but important for backwards compatibility.
- void startCompiling(const QString &name)
+ void startCompiling(const QUrl &url)
{
m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(),
(1 << RangeStart | 1 << RangeLocation | 1 << RangeData),
- 1 << Compiling, name, 1, 1));
+ 1 << Compiling, url, 1, 1));
}
void startHandlingSignal(const QQmlSourceLocation &location)
@@ -217,10 +218,10 @@ struct QQmlHandlingSignalProfiler : public QQmlProfilerHelper {
};
struct QQmlCompilingProfiler : public QQmlProfilerHelper {
- QQmlCompilingProfiler(QQmlProfiler *profiler, const QString &name) :
+ QQmlCompilingProfiler(QQmlProfiler *profiler, const QUrl &url) :
QQmlProfilerHelper(profiler)
{
- Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCompiling, profiler, startCompiling(name));
+ Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCompiling, profiler, startCompiling(url));
}
~QQmlCompilingProfiler()
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 408f17ffd..eb65f732d 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -647,6 +647,8 @@ void QQmlDataBlob::notifyComplete(QQmlDataBlob *blob)
{
Q_ASSERT(m_waitingFor.contains(blob));
Q_ASSERT(blob->status() == Error || blob->status() == Complete);
+ QQmlCompilingProfiler prof(QQmlEnginePrivate::get(typeLoader()->engine())->profiler,
+ blob->url());
m_inCallback = true;
@@ -1194,6 +1196,8 @@ void QQmlTypeLoader::setData(QQmlDataBlob *blob, QQmlFile *file)
void QQmlTypeLoader::setData(QQmlDataBlob *blob, const QQmlDataBlob::Data &d)
{
QML_MEMORY_SCOPE_URL(blob->url());
+ QQmlCompilingProfiler prof(QQmlEnginePrivate::get(engine())->profiler, blob->url());
+
blob->m_inCallback = true;
blob->dataReceived(d);
@@ -1212,6 +1216,8 @@ void QQmlTypeLoader::setData(QQmlDataBlob *blob, const QQmlDataBlob::Data &d)
void QQmlTypeLoader::setCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit)
{
QML_MEMORY_SCOPE_URL(blob->url());
+ QQmlCompilingProfiler prof(QQmlEnginePrivate::get(engine())->profiler, blob->url());
+
blob->m_inCallback = true;
blob->initializeFromCachedUnit(unit);
@@ -2253,8 +2259,6 @@ void QQmlTypeData::compile()
m_compiledData = new QQmlCompiledData(typeLoader()->engine());
- QQmlCompilingProfiler prof(QQmlEnginePrivate::get(typeLoader()->engine())->profiler, finalUrlString());
-
QQmlTypeCompiler compiler(QQmlEnginePrivate::get(typeLoader()->engine()), m_compiledData, this, m_document.data());
if (!compiler.compile()) {
setError(compiler.compilationErrors());