From 72d1850a0df56530307c6111dacf0f47932acc04 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 7 Mar 2014 13:04:04 +0100 Subject: [PATCH] QmlProfiler: Cache file lookup when loading events The file lookup is the single most expensive operation when loading events from a profiled application, in particular because so far we're doing one lookup per source location, many of which are actually in the same files. Caching those lookups for a short time dramatically increases performance. Change-Id: Iaa47327aca3f34cbad194757d3ba152205788682 Reviewed-by: Kai Koehne --- .../qmlprofiler/qmlprofilerdetailsrewriter.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmlprofiler/qmlprofilerdetailsrewriter.cpp b/src/plugins/qmlprofiler/qmlprofilerdetailsrewriter.cpp index 91ab11adc43..38b08087748 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdetailsrewriter.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerdetailsrewriter.cpp @@ -108,6 +108,7 @@ public: QList m_pendingEvents; QStringList m_pendingDocs; Utils::FileInProjectFinder *m_projectFinder; + QMap m_filesCache; QmlProfilerDetailsRewriter *q; }; @@ -125,7 +126,13 @@ QmlProfilerDetailsRewriter::~QmlProfilerDetailsRewriter() void QmlProfilerDetailsRewriter::requestDetailsForLocation(int requestId, const QmlDebug::QmlEventLocation &location) { - const QString localFile = d->m_projectFinder->findFile(location.filename); + QString localFile; + if (!d->m_filesCache.contains(location.filename)) { + localFile = d->m_projectFinder->findFile(location.filename); + d->m_filesCache[location.filename] = localFile; + } else { + localFile = d->m_filesCache[location.filename]; + } QFileInfo fileInfo(localFile); if (!fileInfo.exists() || !fileInfo.isReadable()) return; @@ -173,6 +180,7 @@ void QmlProfilerDetailsRewriter::rewriteDetailsForLocation(QTextStream &textDoc, void QmlProfilerDetailsRewriter::clearRequests() { + d->m_filesCache.clear(); d->m_pendingDocs.clear(); } @@ -204,6 +212,7 @@ void QmlProfilerDetailsRewriter::documentReady(QmlJS::Document::Ptr doc) this, SLOT(documentReady(QmlJS::Document::Ptr))); emit eventDetailsChanged(); + d->m_filesCache.clear(); } }