aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4profiling.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime/qv4profiling.cpp')
-rw-r--r--src/qml/jsruntime/qv4profiling.cpp47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/qml/jsruntime/qv4profiling.cpp b/src/qml/jsruntime/qv4profiling.cpp
index a7019d0558..b62f367601 100644
--- a/src/qml/jsruntime/qv4profiling.cpp
+++ b/src/qml/jsruntime/qv4profiling.cpp
@@ -32,12 +32,13 @@
****************************************************************************/
#include "qv4profiling_p.h"
-#include "qv4mm_p.h"
+#include <private/qv4mm_p.h>
+#include <private/qv4string_p.h>
QT_BEGIN_NAMESPACE
-using namespace QV4;
-using namespace QV4::Profiling;
+namespace QV4 {
+namespace Profiling {
FunctionCallProperties FunctionCall::resolve() const
{
@@ -55,42 +56,43 @@ FunctionCallProperties FunctionCall::resolve() const
Profiler::Profiler(QV4::ExecutionEngine *engine) : featuresEnabled(0), m_engine(engine)
{
- static int metatype = qRegisterMetaType<QList<QV4::Profiling::FunctionCallProperties> >();
- static int metatype2 = qRegisterMetaType<QList<QV4::Profiling::MemoryAllocationProperties> >();
- Q_UNUSED(metatype);
- Q_UNUSED(metatype2);
+ static int meta = qRegisterMetaType<QVector<QV4::Profiling::FunctionCallProperties> >();
+ static int meta2 = qRegisterMetaType<QVector<QV4::Profiling::MemoryAllocationProperties> >();
+ Q_UNUSED(meta);
+ Q_UNUSED(meta2);
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()
{
- QList<FunctionCallProperties> resolved;
+ 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();
}
void Profiler::startProfiling(quint64 features)
{
if (featuresEnabled == 0) {
- m_data.clear();
- m_memory_data.clear();
-
if (features & (1 << FeatureMemoryAllocation)) {
qint64 timestamp = m_timer.nsecsElapsed();
MemoryAllocationProperties heap = {timestamp,
@@ -111,4 +113,7 @@ void Profiler::startProfiling(quint64 features)
}
}
+} // namespace Profiling
+} // namespace QV4
+
QT_END_NAMESPACE