OpenCoverage

qv4profiling.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4profiling.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQml module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qv4profiling_p.h"-
41#include <private/qv4mm_p.h>-
42#include <private/qv4string_p.h>-
43-
44QT_BEGIN_NAMESPACE-
45-
46namespace QV4 {-
47namespace Profiling {-
48-
49FunctionLocation FunctionCall::resolveLocation() const-
50{-
51 return FunctionLocation(m_function->name()->toQString(),
executed 8 times by 1 test: return FunctionLocation(m_function->name()->toQString(), m_function->compilationUnit->fileName(), m_function->compiledFunction->location.line, m_function->compiledFunction->location.column);
Executed by:
  • tst_qqmlprofilerservice
8
52 m_function->compilationUnit->fileName(),
executed 8 times by 1 test: return FunctionLocation(m_function->name()->toQString(), m_function->compilationUnit->fileName(), m_function->compiledFunction->location.line, m_function->compiledFunction->location.column);
Executed by:
  • tst_qqmlprofilerservice
8
53 m_function->compiledFunction->location.line,
executed 8 times by 1 test: return FunctionLocation(m_function->name()->toQString(), m_function->compilationUnit->fileName(), m_function->compiledFunction->location.line, m_function->compiledFunction->location.column);
Executed by:
  • tst_qqmlprofilerservice
8
54 m_function->compiledFunction->location.column);
executed 8 times by 1 test: return FunctionLocation(m_function->name()->toQString(), m_function->compilationUnit->fileName(), m_function->compiledFunction->location.line, m_function->compiledFunction->location.column);
Executed by:
  • tst_qqmlprofilerservice
8
55}-
56-
57FunctionCallProperties FunctionCall::properties() const-
58{-
59 FunctionCallProperties props = {-
60 m_start,-
61 m_end,-
62 reinterpret_cast<quintptr>(m_function)-
63 };-
64 return props;
executed 14 times by 1 test: return props;
Executed by:
  • tst_qqmlprofilerservice
14
65}-
66-
67Profiler::Profiler(QV4::ExecutionEngine *engine) : featuresEnabled(0), m_engine(engine)-
68{-
69 static const int metatypes[] = {-
70 qRegisterMetaType<QVector<QV4::Profiling::FunctionCallProperties> >(),-
71 qRegisterMetaType<QVector<QV4::Profiling::MemoryAllocationProperties> >(),-
72 qRegisterMetaType<FunctionLocationHash>()-
73 };-
74 Q_UNUSED(metatypes);-
75 m_timer.start();-
76}
executed 32 times by 3 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmlprofilerservice
32
77-
78void Profiler::stopProfiling()-
79{-
80 featuresEnabled = 0;-
81 reportData();-
82 m_sentLocations.clear();-
83}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qqmlprofilerservice
6
84-
85bool operator<(const FunctionCall &call1, const FunctionCall &call2)-
86{-
87 return call1.m_start < call2.m_start ||
executed 8 times by 1 test: 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)));
Executed by:
  • tst_qqmlprofilerservice
8
88 (call1.m_start == call2.m_start && (call1.m_end < call2.m_end ||
executed 8 times by 1 test: 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)));
Executed by:
  • tst_qqmlprofilerservice
8
89 (call1.m_end == call2.m_end && call1.m_function < call2.m_function)));
executed 8 times by 1 test: 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)));
Executed by:
  • tst_qqmlprofilerservice
8
90}-
91-
92void Profiler::reportData()-
93{-
94 std::sort(m_data.begin(), m_data.end());-
95 QVector<FunctionCallProperties> properties;-
96 FunctionLocationHash locations;-
97 properties.reserve(m_data.size());-
98-
99 for (const FunctionCall &call : qAsConst(m_data)) {-
100 properties.append(call.properties());-
101 Function *function = call.function();-
102 SentMarker &marker = m_sentLocations[reinterpret_cast<quintptr>(function)];-
103 if (!marker.isValid()) {
!marker.isValid()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmlprofilerservice
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmlprofilerservice
6-8
104 FunctionLocation &location = locations[properties.constLast().id];-
105 if (!location.isValid())
!location.isValid()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmlprofilerservice
FALSEnever evaluated
0-8
106 location = call.resolveLocation();
executed 8 times by 1 test: location = call.resolveLocation();
Executed by:
  • tst_qqmlprofilerservice
8
107 marker.setFunction(function);-
108 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qqmlprofilerservice
8
109 }
executed 14 times by 1 test: end of block
Executed by:
  • tst_qqmlprofilerservice
14
110-
111 emit dataReady(locations, properties, m_memory_data);-
112 m_data.clear();-
113 m_memory_data.clear();-
114}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qqmlprofilerservice
6
115-
116void Profiler::startProfiling(quint64 features)-
117{-
118 if (featuresEnabled == 0) {
featuresEnabled == 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmlprofilerservice
FALSEnever evaluated
0-6
119 if (features & (1 << FeatureMemoryAllocation)) {
features & (1 ...oryAllocation)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmlprofilerservice
FALSEnever evaluated
0-6
120 qint64 timestamp = m_timer.nsecsElapsed();-
121 MemoryAllocationProperties heap = {timestamp,-
122 (qint64)m_engine->memoryManager->getAllocatedMem() --
123 (qint64)m_engine->memoryManager->getLargeItemsMem(),-
124 HeapPage};-
125 m_memory_data.append(heap);-
126 MemoryAllocationProperties small = {timestamp,-
127 (qint64)m_engine->memoryManager->getUsedMem(),-
128 SmallItem};-
129 m_memory_data.append(small);-
130 MemoryAllocationProperties large = {timestamp,-
131 (qint64)m_engine->memoryManager->getLargeItemsMem(),-
132 LargeItem};-
133 m_memory_data.append(large);-
134 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qqmlprofilerservice
6
135-
136 featuresEnabled = features;-
137 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qqmlprofilerservice
6
138}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qqmlprofilerservice
6
139-
140} // namespace Profiling-
141} // namespace QV4-
142-
143QT_END_NAMESPACE-
144-
145#include "moc_qv4profiling_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0