Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmljscompilerstatsreporter.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3// Qt-Security score:significant
4
6
7#include <QFileInfo>
8
10
11namespace QQmlJS {
12
13using namespace Qt::StringLiterals;
14
39
41{
42 s << "############ AOT COMPILATION STATS ############\n";
45 for (const auto &moduleUri : std::as_const(sortedModuleKeys)) {
46 const auto &fileStats = m_aotstats.entries()[moduleUri];
47 s << u"Module %1:\n"_s.arg(moduleUri);
48 if (fileStats.empty()) {
49 s << "No attempts at compiling a binding or function\n";
50 continue;
51 }
52
55 for (const auto &filename : std::as_const(sortedFileKeys)) {
56 const auto &entries = fileStats[filename];
57 s << u"--File %1\n"_s.arg(filename);
58 if (entries.empty()) {
59 s << " No attempts at compiling a binding or function\n";
60 continue;
61 }
62
65 s << " " << formatSuccessRate(entries.size(), successes, skips) << "\n";
66
67 for (const auto &stat : std::as_const(entries)) {
68 s << u" %1: [%2:%3:%4]\n"_s.arg(stat.functionName)
70 .arg(stat.line)
71 .arg(stat.column);
72 s << u" result: "_s;
73 switch (stat.codegenResult) {
74 case QQmlJS::CodegenResult::Success: s << u"Success\n"_s;
75 break;
76 case QQmlJS::CodegenResult::Skip: s << u"Skip: %1\n"_s.arg(stat.message);
77 break;
78 case QQmlJS::CodegenResult::Failure: s << u"Error: %1\n"_s.arg(stat.message);
79 break;
80 }
81 s << u" duration: %1us\n"_s.arg(stat.codegenDuration.count());
82 }
83 s << "\n";
84 }
85 }
86}
87
89{
90 s << "############ AOT COMPILATION STATS SUMMARY ############\n";
92 s << "No attempted compilations to Cpp for bindings or functions.\n";
93 return;
94 }
95
98 for (const auto &moduleUri : std::as_const(sortedKeys)) {
99 const auto &counters = m_moduleCounters[moduleUri];
100 s << u"Module %1: "_s.arg(moduleUri)
102 }
103
104 for (const auto &module : std::as_const(m_emptyModules))
105 s << u"Module %1: No .qml files to compile.\n"_s.arg(module);
106
107 for (const auto &module : std::as_const(m_onlyBytecodeModules))
108 s << u"Module %1: No .qml files compiled (--only-bytecode).\n"_s.arg(module);
109
110 s << "Total results: " << formatSuccessRate(m_totalCounters.codegens,
113 s << "\n";
114
115 if (m_totalCounters.successes != 0) {
117 std::chrono::microseconds(0));
119 s << u"Successful codegens took an average of %1us\n"_s.arg(averageDuration);
120 }
121}
122
124{
127
130
131 return output;
132}
133
135{
136 if (codegens == 0)
137 return u"No attempted compilations"_s;
138
139 return u"%1 of %2 (%3%4) %5bindings or functions compiled to Cpp successfully"_s
140 .arg(successes)
141 .arg(codegens)
142 .arg(double(successes) / codegens * 100, 0, 'g', 4)
143 .arg(u"%"_s)
144 .arg(skips ? u"(%1 skipped) "_s.arg(skips) : u""_s);
145}
146
147} // namespace QQmlJS
148
149QT_END_NAMESPACE