Use Nanotrace to generate startup performance report

Add various trace points to the code, including the plugin
initialization methods (centrally in plugin manager), code that is
scheduled on the event loop with QTimer::singleShot or
QMetaObject::invokeMethod during initialization, and code that is
triggered from ICore::coreOpened

Can be turned on by configuring with `BUILD_LIBRARY_NANOTRACE=ON`
Run with `-trace <file>` to write trace file. If Nanotrace is not built,
the added code expands to nothing.

Changes in Nanotrace:
- turned generated data to microseconds instead of nanoseconds, because
  that is what Chrome tracing expects
- fixed serialization of duration (needs to be an item of the event, not
  in a "arg" subitem)
- fixed shutdown() to reset the initEvent

Change-Id: I994de82023b820d771e1be0a859ebd8da0b73d4d
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Eike Ziller
2023-08-30 15:04:29 +02:00
parent 66c8eda943
commit dab19c4a8c
24 changed files with 198 additions and 77 deletions

View File

@@ -61,6 +61,8 @@
#include <vcsbase/vcscommand.h>
#include <vcsbase/vcsoutputwindow.h>
#include <nanotrace/nanotrace.h>
#include <QAction>
#include <QApplication>
#include <QDebug>
@@ -680,6 +682,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
auto cmdContext = new QObject(this);
connect(ICore::instance(), &ICore::coreOpened, cmdContext, [this, cmdContext, arguments] {
NANOTRACE_SCOPE("Git", "GitPlugin::initialize::coreOpened");
remoteCommand(arguments, QDir::currentPath(), {});
cmdContext->deleteLater();
});