Build nanotrace profiling by default

And enable its availability for startup performance measurement.
Makes it possible to run with `-trace <filepath>`, creating a CTF for
startup performance, without requiring a special QtC build.

Usage in QmlDesigner/DesignStudio is guarded by an additional
DESIGNSTUDIO_USE_NANOTRACE CMake option (default off), since that adds a
menu item that should usually not be shown.

Change-Id: I87200745cc32f256bcaaba21f139b4104459e49a
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
This commit is contained in:
Eike Ziller
2024-01-19 15:31:22 +01:00
parent 7d7f97a747
commit 1a84ae038d
7 changed files with 15 additions and 9 deletions

View File

@@ -1,5 +1,4 @@
add_qtc_library(Nanotrace
BUILD_DEFAULT OFF
PUBLIC_DEFINES NANOTRACE_ENABLED
SOURCES
nanotraceglobals.h
@@ -10,3 +9,10 @@ add_qtc_library(Nanotrace
CXX_VISIBILITY_PRESET default
VISIBILITY_INLINES_HIDDEN OFF
)
option(DESIGNSTUDIO_USE_NANOTRACE
"Enables collecting performance data with nanotrace for Design Studio" OFF)
extend_qtc_library(Nanotrace
CONDITION DESIGN_STUDIO_USE_NANOTRACE
PUBLIC_DEFINES NANOTRACE_DESIGNSTUDIO_ENABLED
)

View File

@@ -54,7 +54,7 @@ enum class View3DActionType {
constexpr bool isNanotraceEnabled()
{
#ifdef NANOTRACE_ENABLED
#ifdef NANOTRACE_DESIGNSTUDIO_ENABLED
return true;
#else
return false;

View File

@@ -106,7 +106,7 @@ void BaseConnectionManager::readDataStream(Connection &connection)
in >> command;
connection.blockSize = 0;
#ifdef NANOTRACE_ENABLED
#ifdef NANOTRACE_DESIGNSTUDIO_ENABLED
if (command.typeId() != QMetaType::type("PuppetAliveCommand")) {
if (command.typeId() == QMetaType::type("SyncNanotraceCommand")) {
SyncNanotraceCommand cmd = command.value<SyncNanotraceCommand>();

View File

@@ -172,7 +172,7 @@ QString NodeInstanceServerProxy::qrcMappingString() const
void NodeInstanceServerProxy::writeCommand(const QVariant &command)
{
#ifdef NANOTRACE_ENABLED
#ifdef NANOTRACE_DESIGNSTUDIO_ENABLED
if (command.typeId() == QMetaType::type("SyncNanotraceCommand")) {
SyncNanotraceCommand cmd = command.value<SyncNanotraceCommand>();
NANOTRACE_INSTANT_ARGS("Sync", "writeCommand",

View File

@@ -58,7 +58,7 @@
// Nanotrace headers are not exported to build dir at all if the feature is disabled, so
// runtime puppet build can't find them.
#if NANOTRACE_ENABLED
#if NANOTRACE_DESIGNSTUDIO_ENABLED
#include "nanotrace/nanotrace.h"
#else
#define NANOTRACE_INIT(process, thread, filepath)
@@ -185,7 +185,7 @@ void NodeInstanceClientProxy::writeCommand(const QVariant &command)
exit(-1);
}
} else if (m_outputIoDevice) {
#ifdef NANOTRACE_ENABLED
#ifdef NANOTRACE_DESIGNSTUDIO_ENABLED
if (command.typeId() != QMetaType::type("PuppetAliveCommand")) {
if (command.typeId() == QMetaType::type("SyncNanotraceCommand")) {
SyncNanotraceCommand cmd = command.value<SyncNanotraceCommand>();
@@ -390,7 +390,7 @@ void NodeInstanceClientProxy::readDataStream()
static quint32 blockSize = 0;
QVariant command = readCommandFromIOStream(m_inputIoDevice, &readCommandCounter, &blockSize);
#ifdef NANOTRACE_ENABLED
#ifdef NANOTRACE_DESIGNSTUDIO_ENABLED
if (command.typeId() != QMetaType::type("EndNanotraceCommand")) {
if (command.typeId() == QMetaType::type("SyncNanotraceCommand")) {
SyncNanotraceCommand cmd = command.value<SyncNanotraceCommand>();

View File

@@ -50,7 +50,7 @@
// Nanotrace headers are not exported to build dir at all if the feature is disabled, so
// runtime puppet build can't find them.
#if NANOTRACE_ENABLED
#if NANOTRACE_DESIGNSTUDIO_ENABLED
#include "nanotrace/nanotrace.h"
#else
#define NANOTRACE_SCOPE(cat, name)

View File

@@ -19,7 +19,7 @@
// Nanotrace headers are not exported to build dir at all if the feature is disabled, so
// runtime puppet build can't find them.
#if NANOTRACE_ENABLED
#if NANOTRACE_DESIGNSTUDIO_ENABLED
#include "nanotrace/nanotrace.h"
#else
#define NANOTRACE_SCOPE(cat, name)