Nanotracer: Simplify templates

Change-Id: Iec6e80ec7622b9fc9162c6852d3736e505c8feff
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2025-06-01 21:45:01 +02:00
parent cdc0a2c9b4
commit 87e52c1998
13 changed files with 663 additions and 636 deletions

View File

@@ -50,12 +50,6 @@ constexpr bool isArgumentValid(const ArgumentsString &string)
return string.isValid() && string.size();
}
template<typename String>
constexpr bool isArgumentValid(const String &string)
{
return string.size();
}
template<typename TraceEvent>
void printEvent(std::ostream &out, const TraceEvent &event, qint64 processId, std::thread::id threadId)
{

File diff suppressed because it is too large Load Diff

View File

@@ -543,10 +543,10 @@ public:
using TracerCategory = std::decay_t<decltype(sqliteHighLevelCategory())>;
StatementImplementation &m_statement;
const source_location &m_sourceLocation;
NanotraceHR::Tracer<TracerCategory, typename TracerCategory::IsActive> tracer{
"range",
NanotraceHR::Tracer<TracerCategory> tracer{"range",
sqliteHighLevelCategory(),
NanotraceHR::keyValue("sqlite statement", m_statement.handle())};
NanotraceHR::keyValue("sqlite statement",
m_statement.handle())};
};
template<typename ResultType>

View File

@@ -25,8 +25,8 @@ public:
~TaskQueue() { destroy(); }
template<typename TraceEvent, NanotraceHR::Tracing isEnabled, typename... Arguments>
void addTask(NanotraceHR::Token<TraceEvent, isEnabled> traceToken, Arguments &&...arguments)
template<typename Category, typename... Arguments>
void addTask(NanotraceHR::Token<Category> traceToken, Arguments &&...arguments)
{
{
std::unique_lock lock{m_mutex};

View File

@@ -20,17 +20,17 @@ namespace ImageCache {
#ifdef ENABLE_IMAGE_CACHE_TRACING
using Category = NanotraceHR::EnabledCategory;
using TraceToken = Category::FlowTokenType;
using FlowToken = Category::FlowTokenType;
using Token = Category::TokenType;
using TraceToken = NanotraceHR::EnabledFlowToken;
using FlowToken = NanotraceHR::EnabledFlowToken;
using Token = NanotraceHR::EnabledToken;
[[gnu::pure]] QMLDESIGNERCORE_EXPORT Category &category();
#else
using Category = NanotraceHR::DisabledCategory;
using TraceToken = Category::FlowTokenType;
using FlowToken = Category::FlowTokenType;
using Token = Category::TokenType;
using TraceToken = NanotraceHR::DisabledFlowToken;
using FlowToken = NanotraceHR::DisabledFlowToken;
using Token = NanotraceHR::DisabledToken;
inline Category category()
{

View File

@@ -59,7 +59,7 @@ public:
int majorVersion,
int minorVersion,
qint32 internalId,
ModelTracing::Category::FlowTokenType flowTraceToken)
ModelTracing::FlowToken flowTraceToken)
: typeName(typeName.toByteArray())
, majorVersion(majorVersion)
, minorVersion(minorVersion)

View File

@@ -30,7 +30,7 @@
namespace QmlDesigner {
constexpr auto category = ProjectStorageTracing::projectStorageUpdaterCategory;
using NanotraceHR::keyValue;
using Tracer = ProjectStorageTracing::Category::TracerType;
using Tracer = NanotraceHR::Tracer<ProjectStorageTracing::Category>;
template<typename String>
void convertToString(String &string, const ProjectStorageUpdater::FileState &state)

View File

@@ -168,7 +168,7 @@ private:
NotUpdatedSourceIds &notUpdatedSourceIds,
WatchedSourceIds &WatchedSourceIds,
IsInsideProject isInsideProject,
ProjectStorageTracing::Category::TracerType &tracer);
NanotraceHR::Tracer<ProjectStorageTracing::Category> &tracer);
void annotationDirectoryChanged(Utils::SmallStringView directoryPath,
DirectoryPathId directoryId,
DirectoryPathId annotationDirectoryId,

View File

@@ -26,7 +26,7 @@ namespace QmlDesigner {
constexpr auto category = ProjectStorageTracing::projectStorageUpdaterCategory;
using NanotraceHR::keyValue;
using Storage::IsInsideProject;
using Tracer = ProjectStorageTracing::Category::TracerType;
using Tracer = NanotraceHR::Tracer<ProjectStorageTracing::Category>;
namespace QmlDom = QQmlJS::Dom;
namespace Synchronization = Storage::Synchronization;

View File

@@ -28,7 +28,7 @@ namespace QmlDesigner {
constexpr auto category = ProjectStorageTracing::projectStorageUpdaterCategory;
using NanotraceHR::keyValue;
using Storage::IsInsideProject;
using Tracer = ProjectStorageTracing::Category::TracerType;
using Tracer = NanotraceHR::Tracer<ProjectStorageTracing::Category>;
using Storage::ModuleKind;
namespace QmlDom = QQmlJS::Dom;

View File

@@ -9,10 +9,10 @@ namespace QmlDesigner {
using namespace NanotraceHR::Literals;
#ifdef ENABLE_QMLDESIGNER_TRACING
namespace Tracing {
#ifdef ENABLE_QMLDESIGNER_TRACING
namespace {
using TraceFile = NanotraceHR::EnabledTraceFile;
@@ -42,6 +42,8 @@ EventQueueWithoutArguments &eventQueueWithoutArguments()
return eventQueue;
}
#endif
} // namespace Tracing
namespace ModelTracing {
@@ -112,6 +114,4 @@ Category &category()
} // namespace SourcePathStorageTracing
#endif
} // namespace QmlDesigner

View File

@@ -28,14 +28,16 @@ namespace ModelTracing {
using Category = NanotraceHR::EnabledCategory;
using SourceLocation = Category::SourceLocation;
using AsynchronousToken = Category::AsynchronousTokenType;
using AsynchronousToken = NanotraceHR::EnabledAsynchronousToken;
using FlowToken = NanotraceHR::EnabledFlowToken;
[[gnu::pure]] QMLDESIGNERCORE_EXPORT Category &category();
#else
using Category = NanotraceHR::DisabledCategory;
using SourceLocation = Category::SourceLocation;
using AsynchronousToken = Category::AsynchronousTokenType;
using AsynchronousToken = NanotraceHR::DisabledAsynchronousToken;
using FlowToken = NanotraceHR::DisabledFlowToken;
inline Category category()
{

View File

@@ -26,8 +26,6 @@ auto IsTask(Matcher matcher)
class TaskQueue : public testing::Test
{
using Category = NanotraceHR::DisabledCategory;
protected:
Notification notification;
Notification waitInThread;
@@ -36,7 +34,7 @@ protected:
using Queue = QmlDesigner::TaskQueue<Task,
decltype(mockDispatchCallback.AsStdFunction()),
decltype(mockCleanCallback.AsStdFunction())>;
NanotraceHR::Token<Category, NanotraceHR::Tracing::IsDisabled> dummyToken;
NanotraceHR::DisabledToken dummyToken;
};
TEST_F(TaskQueue, add_task_dispatches_task)