From a2e64a20777867726b51a9c9196dc1b8dd68f512 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 21 Apr 2016 16:57:10 +0200 Subject: V4 profiler: Don't duplicate function locations Saving the name/file/line/column over and over for each function call is wasteful. We can instead key them by the pointer to the JS Function object. Also, make sure we don't accidentally detach the data when sending messages. Task-number: QTBUG-52937 Change-Id: I8a03e4003dc3239f88b49c56424df05cd8b9ef8a Reviewed-by: Anton Kudryavtsev Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4profiling.cpp | 40 +++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'src/qml/jsruntime/qv4profiling.cpp') diff --git a/src/qml/jsruntime/qv4profiling.cpp b/src/qml/jsruntime/qv4profiling.cpp index c0a4129d9d..a59190b846 100644 --- a/src/qml/jsruntime/qv4profiling.cpp +++ b/src/qml/jsruntime/qv4profiling.cpp @@ -46,26 +46,35 @@ QT_BEGIN_NAMESPACE namespace QV4 { namespace Profiling { -FunctionCallProperties FunctionCall::resolve() const +FunctionLocation FunctionCall::resolveLocation() const { - FunctionCallProperties props = { - m_start, - m_end, + FunctionLocation location = { m_function->name()->toQString(), m_function->compilationUnit->fileName(), m_function->compiledFunction->location.line, m_function->compiledFunction->location.column }; - return props; + return location; } +FunctionCallProperties FunctionCall::properties() const +{ + FunctionCallProperties props = { + m_start, + m_end, + reinterpret_cast(m_function) + }; + return props; +} Profiler::Profiler(QV4::ExecutionEngine *engine) : featuresEnabled(0), m_engine(engine) { - static int meta = qRegisterMetaType >(); - static int meta2 = qRegisterMetaType >(); - Q_UNUSED(meta); - Q_UNUSED(meta2); + static const int metatypes[] = { + qRegisterMetaType >(), + qRegisterMetaType >(), + qRegisterMetaType() + }; + Q_UNUSED(metatypes); m_timer.start(); } @@ -85,13 +94,16 @@ bool operator<(const FunctionCall &call1, const FunctionCall &call2) void Profiler::reportData() { std::sort(m_data.begin(), m_data.end()); - QVector resolved; - resolved.reserve(m_data.size()); + QVector properties; + QHash locations; + properties.reserve(m_data.size()); - foreach (const FunctionCall &call, m_data) - resolved.append(call.resolve()); + foreach (const FunctionCall &call, m_data) { + properties.append(call.properties()); + locations[properties.constLast().id] = call.resolveLocation(); + } - emit dataReady(resolved, m_memory_data); + emit dataReady(locations, properties, m_memory_data); m_data.clear(); m_memory_data.clear(); } -- cgit v1.2.3