diff options
author | Olivier De Cannière <[email protected]> | 2024-05-24 13:21:44 +0200 |
---|---|---|
committer | Olivier De Cannière <[email protected]> | 2024-05-28 10:25:41 +0200 |
commit | 8827af0fe87270739c611ece091eb51c234dde3c (patch) | |
tree | 661858349e27f97cb443fc8791bbe9b9d68ac703 /tools/qmlcachegen/qmlcachegen.cpp | |
parent | b803c5baaf67cbeb80a172c6a556d6deb044338b (diff) |
Compiler: Record statistics about aot compilation
This patch introduces the collection of statistics about the
ahead-of-time compilation of functions and bindings to Cpp by
qmlcachegen. This is done by having qmlcachegen save an aotstats file
for every qml file it compiles. This file contains, for every function
and binding, whether the Cpp codegen was successful, its duration and a
potential error message
Task-number: QTBUG-124667
Change-Id: Iba9a72be04f6642688533a3ae12ea687296c85e1
Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'tools/qmlcachegen/qmlcachegen.cpp')
-rw-r--r-- | tools/qmlcachegen/qmlcachegen.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp index d16795f9d5..37a2298717 100644 --- a/tools/qmlcachegen/qmlcachegen.cpp +++ b/tools/qmlcachegen/qmlcachegen.cpp @@ -101,6 +101,11 @@ int main(int argc, char **argv) QCommandLineOption validateBasicBlocksOption("validate-basic-blocks"_L1, QCoreApplication::translate("main", "Performs checks on the basic blocks of a function compiled ahead of time to validate its structure and coherence")); parser.addOption(validateBasicBlocksOption); + QCommandLineOption dumpAotStatsOption("dump-aot-stats"_L1, QCoreApplication::translate("main", "Dumps statistics about ahead-of-time compilation of bindings and functions")); + parser.addOption(dumpAotStatsOption); + QCommandLineOption moduleIdOption("module-id"_L1, QCoreApplication::translate("main", "Identifies the module of the qml file being compiled for aot stats"), QCoreApplication::translate("main", "id")); + parser.addOption(moduleIdOption); + QCommandLineOption outputFileOption("o"_L1, QCoreApplication::translate("main", "Output file name"), QCoreApplication::translate("main", "file name")); parser.addOption(outputFileOption); @@ -135,6 +140,11 @@ int main(int argc, char **argv) if (target == GenerateLoader && parser.isSet(resourceNameOption)) target = GenerateLoaderStandAlone; + if (parser.isSet(dumpAotStatsOption) && !parser.isSet(moduleIdOption)) { + fprintf(stderr, "--dump-aot-stats set without setting --module-id"); + return EXIT_FAILURE; + } + const QStringList sources = parser.positionalArguments(); if (sources.isEmpty()){ parser.showHelp(); @@ -261,6 +271,11 @@ int main(int argc, char **argv) &importer, u':' + inputResourcePath, QQmlJSUtils::cleanPaths(parser.values(importsOption)), &logger); + if (parser.isSet(dumpAotStatsOption)) { + QQmlJS::QQmlJSAotCompilerStats::setRecordAotStats(true); + QQmlJS::QQmlJSAotCompilerStats::setModuleId(parser.value(moduleIdOption)); + } + if (parser.isSet(validateBasicBlocksOption)) cppCodeGen.m_flags.setFlag(QQmlJSAotCompiler::ValidateBasicBlocks); @@ -279,6 +294,9 @@ int main(int argc, char **argv) if (parser.isSet(warningsAreErrorsOption)) return EXIT_FAILURE; } + + if (parser.isSet(dumpAotStatsOption)) + QQmlJS::QQmlJSAotCompilerStats::instance()->saveToDisk(outputFileName + u".aotstats"_s); } } else if (inputFile.endsWith(".js"_L1) || inputFile.endsWith(".mjs"_L1)) { QQmlJSCompileError error; |