diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-08-13 18:15:43 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-08-24 19:24:25 +0000 |
commit | ce5c468f36286e251d3dfee3496faf240dc0e92d (patch) | |
tree | 619dfae870b05672b58b8a4be86801fa78fe61b9 /src/qml/jsruntime/qv4profiling.cpp | |
parent | 6d5caee804ca80eb81c364624847f70e62caa92e (diff) |
std::sort JS profiling data instead of insert-sorting it
The original FunctionCall struct is much smaller than the resulting
FunctionCallProperties, and thus not as expensive to copy. Repeatedly
calling upper_bound on a QVector is not such a great idea, either.
Since the usage of QVector instead of QList for the results is new
in Qt 5.6, the insert-sorting got slower, making this change a fix
for a performance regression.
Change-Id: I7154d8cf129b7fbe6e02424fbe16442042a5c3c2
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime/qv4profiling.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4profiling.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/qml/jsruntime/qv4profiling.cpp b/src/qml/jsruntime/qv4profiling.cpp index 9b77599904..b62f367601 100644 --- a/src/qml/jsruntime/qv4profiling.cpp +++ b/src/qml/jsruntime/qv4profiling.cpp @@ -37,8 +37,8 @@ QT_BEGIN_NAMESPACE -using namespace QV4; -using namespace QV4::Profiling; +namespace QV4 { +namespace Profiling { FunctionCallProperties FunctionCall::resolve() const { @@ -63,26 +63,28 @@ Profiler::Profiler(QV4::ExecutionEngine *engine) : featuresEnabled(0), m_engine( m_timer.start(); } -struct FunctionCallComparator { - bool operator()(const FunctionCallProperties &p1, const FunctionCallProperties &p2) - { return p1.start < p2.start; } -}; - void Profiler::stopProfiling() { featuresEnabled = 0; reportData(); } +bool operator<(const FunctionCall &call1, const FunctionCall &call2) +{ + return call1.m_start < call2.m_start || + (call1.m_start == call2.m_start && (call1.m_end < call2.m_end || + (call1.m_end == call2.m_end && call1.m_function < call2.m_function))); +} + void Profiler::reportData() { + std::sort(m_data.begin(), m_data.end()); QVector<FunctionCallProperties> resolved; resolved.reserve(m_data.size()); - FunctionCallComparator comp; - foreach (const FunctionCall &call, m_data) { - FunctionCallProperties props = call.resolve(); - resolved.insert(std::upper_bound(resolved.begin(), resolved.end(), props, comp), props); - } + + foreach (const FunctionCall &call, m_data) + resolved.append(call.resolve()); + emit dataReady(resolved, m_memory_data); m_data.clear(); m_memory_data.clear(); @@ -111,4 +113,7 @@ void Profiler::startProfiling(quint64 features) } } +} // namespace Profiling +} // namespace QV4 + QT_END_NAMESPACE |