1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qqmlprofiler_p.h"
5#include "qqmldebugservice_p.h"
6
7QT_BEGIN_NAMESPACE
8
9QQmlProfiler::QQmlProfiler() : featuresEnabled(0)
10{
11 static int metatype = qRegisterMetaType<QVector<QQmlProfilerData> >();
12 static int metatype2 = qRegisterMetaType<QQmlProfiler::LocationHash> ();
13 Q_UNUSED(metatype);
14 Q_UNUSED(metatype2);
15 m_timer.start();
16}
17
18void QQmlProfiler::startProfiling(quint64 features)
19{
20 featuresEnabled = features;
21}
22
23void QQmlProfiler::stopProfiling()
24{
25 featuresEnabled = false;
26 reportData();
27 m_locations.clear();
28}
29
30void QQmlProfiler::reportData()
31{
32 LocationHash resolved;
33 resolved.reserve(size: m_locations.size());
34 for (auto it = m_locations.begin(), end = m_locations.end(); it != end; ++it) {
35 if (!it->sent) {
36 resolved.insert(key: it.key(), value: it.value());
37 it->sent = true;
38 }
39 }
40
41 QVector<QQmlProfilerData> data;
42 data.swap(other&: m_data);
43 emit dataReady(data, resolved);
44}
45
46QT_END_NAMESPACE
47
48#include "moc_qqmlprofiler_p.cpp"
49

source code of qtdeclarative/src/qml/debugger/qqmlprofiler.cpp