8#include <QJsonDocument>
18std::unique_ptr<AotStats> QQmlJSAotCompilerStats::s_instance = std::make_unique<AotStats>();
19QString QQmlJSAotCompilerStats::s_moduleId;
20bool QQmlJSAotCompilerStats::s_recordAotStats =
false;
31 for (
const auto &[moduleUri, moduleStats] :
other.m_entries.asKeyValueRange()) {
32 m_entries[moduleUri].insert(moduleStats);
38 QFile aotstatsListFile(aotstatsListPath);
40 qDebug().noquote() << u
"Could not open \"%1\" for reading"_s.arg(aotstatsListFile.fileName());
47 aotstatsFiles.append(
stream.readLine());
56 qDebug().noquote() << u
"Could not open \"%1\""_s.arg(aotstatsPath);
66 if (!aotstatsFiles.has_value())
70 if (aotstatsFiles->empty())
73 for (
const auto &aotstatsFile : aotstatsFiles.value()) {
75 if (!parsed.has_value())
77 aggregated.insert(parsed.value());
88 for (
const auto &modulesArrayEntry : modulesArray) {
89 const auto &moduleObject = modulesArrayEntry.toObject();
90 QString moduleId = moduleObject[u
"moduleId"_s].toString();
91 const QJsonArray &filesArray = moduleObject[u
"moduleFiles"_s].toArray();
93 QHash<QString, QList<AotStatsEntry>>
files;
94 for (
const auto &filesArrayEntry : filesArray) {
95 const QJsonObject &fileObject = filesArrayEntry.toObject();
96 QString filepath = fileObject[u
"filepath"_s].toString();
97 const QJsonArray &statsArray = fileObject[u
"entries"_s].toArray();
99 QList<AotStatsEntry> stats;
100 for (
const auto &statsArrayEntry : statsArray) {
101 const auto &statsObject = statsArrayEntry.toObject();
103 auto micros = statsObject[u
"durationMicroseconds"_s].toInteger();
105 stat.
functionName = statsObject[u
"functionName"_s].toString();
106 stat.
errorMessage = statsObject[u
"errorMessage"_s].toString();
107 stat.
line = statsObject[u
"line"_s].toInt();
108 stat.
column = statsObject[u
"column"_s].toInt();
110 stats.append(std::move(stat));
113 std::sort(stats.begin(), stats.end());
114 files[filepath] = std::move(stats);
126 for (
auto it1 = m_entries.begin(); it1 != m_entries.end(); ++it1) {
127 const QString moduleId = it1.key();
128 const QHash<QString, QList<AotStatsEntry>> &
files = it1.value();
131 for (
auto it2 =
files.begin(); it2 !=
files.end(); ++it2) {
132 const QString &filename = it2.key();
133 const QList<AotStatsEntry> &stats = it2.value();
136 for (
const auto &stat : stats) {
138 auto micros =
static_cast<qint64>(stat.codegenDuration.count());
139 statObject.
insert(u
"durationMicroseconds", micros);
140 statObject.insert(u
"functionName", stat.functionName);
141 statObject.insert(u
"errorMessage", stat.errorMessage);
142 statObject.insert(u
"line", stat.line);
143 statObject.insert(u
"column", stat.column);
144 statObject.insert(u
"codegenSuccessfull", stat.codegenSuccessful);
145 statsArray.append(statObject);
149 o.insert(u
"filepath"_s, filename);
150 o.insert(u
"entries"_s, statsArray);
151 filesArray.append(
o);
155 o.insert(u
"moduleId"_s, moduleId);
156 o.insert(u
"moduleFiles"_s, filesArray);
157 modulesArray.append(
o);
166 m_entries[moduleId][filepath].append(
entry);
173 qDebug().noquote() << u
"Could not open \"%1\""_s.arg(filepath);
QFILE_MAYBE_NODISCARD bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=nullptr)
Parses json as a UTF-8 encoded JSON document, and creates a QJsonDocument from it.
\inmodule QtCore\reentrant
iterator insert(const QString &key, const QJsonValue &value)
Inserts a new item with the key key and a value of value.
bool saveToDisk(const QString &filepath) const
void addEntry(const QString &moduleId, const QString &filepath, const AotStatsEntry &entry)
void insert(const AotStats &other)
QJsonDocument toJsonDocument() const
static AotStats fromJsonDocument(const QJsonDocument &)
static std::optional< AotStats > aggregateAotstatsList(const QString &aotstatsListPath)
static std::optional< AotStats > parseAotstatsFile(const QString &aotstatsPath)
static AotStats * instance()
static void addEntry(const QString &filepath, const QQmlJS::AotStatsEntry &entry)
\macro QT_RESTRICTED_CAST_FROM_ASCII
std::optional< QList< QString > > extractAotstatsFilesList(const QString &aotstatsListPath)
Combined button and popup list for selecting options.
GLenum GLenum GLsizei void GLsizei void * column
bool operator<(const AotStatsEntry &) const
std::chrono::microseconds codegenDuration