forked from qt-creator/qt-creator
NanoTrace: Simplyfy categories and tracer events
Reduce the template magic. That is creating simpler error messages, too. Change-Id: I57ed3dbfca9a86bc71ecd1a352143a7a5d937a0c Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -45,8 +45,7 @@ unsigned int getUnsignedIntegerHash(std::thread::id id)
|
|||||||
return static_cast<unsigned int>(std::hash<std::thread::id>{}(id) & 0xFFFFFFFF);
|
return static_cast<unsigned int>(std::hash<std::thread::id>{}(id) & 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<std::size_t capacity>
|
constexpr bool isArgumentValid(const ArgumentsString &string)
|
||||||
constexpr bool isArgumentValid(const StaticString<capacity> &string)
|
|
||||||
{
|
{
|
||||||
return string.isValid() && string.size();
|
return string.isValid() && string.size();
|
||||||
}
|
}
|
||||||
@@ -171,7 +170,7 @@ void flushEvents(const Utils::span<TraceEvent> events,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template NANOTRACE_EXPORT void flushEvents(const Utils::span<StringViewWithStringArgumentsTraceEvent> events,
|
template NANOTRACE_EXPORT void flushEvents(const Utils::span<TraceEventWithArguments> events,
|
||||||
std::thread::id threadId,
|
std::thread::id threadId,
|
||||||
std::shared_ptr<EnabledTraceFile> file);
|
std::shared_ptr<EnabledTraceFile> file);
|
||||||
|
|
||||||
@@ -226,8 +225,7 @@ void flushInThread(EnabledEventQueue<TraceEvent> &eventQueue)
|
|||||||
eventQueue.eventsIndex = 0;
|
eventQueue.eventsIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template NANOTRACE_EXPORT void flushInThread(
|
template NANOTRACE_EXPORT void flushInThread(EnabledEventQueue<TraceEventWithArguments> &eventQueue);
|
||||||
EnabledEventQueue<StringViewWithStringArgumentsTraceEvent> &eventQueue);
|
|
||||||
template NANOTRACE_EXPORT void flushInThread(EnabledEventQueue<TraceEventWithoutArguments> &eventQueue);
|
template NANOTRACE_EXPORT void flushInThread(EnabledEventQueue<TraceEventWithoutArguments> &eventQueue);
|
||||||
|
|
||||||
template<typename TraceEvent>
|
template<typename TraceEvent>
|
||||||
@@ -273,8 +271,7 @@ void EventQueue<TraceEvent, Tracing::IsEnabled>::flush()
|
|||||||
file.reset();
|
file.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
template class NANOTRACE_EXPORT_TEMPLATE
|
template class NANOTRACE_EXPORT_TEMPLATE EventQueue<TraceEventWithArguments, Tracing::IsEnabled>;
|
||||||
EventQueue<StringViewWithStringArgumentsTraceEvent, Tracing::IsEnabled>;
|
|
||||||
template class NANOTRACE_EXPORT_TEMPLATE EventQueue<TraceEventWithoutArguments, Tracing::IsEnabled>;
|
template class NANOTRACE_EXPORT_TEMPLATE EventQueue<TraceEventWithoutArguments, Tracing::IsEnabled>;
|
||||||
|
|
||||||
} // namespace NanotraceHR
|
} // namespace NanotraceHR
|
||||||
|
@@ -49,7 +49,7 @@ enum class Tracing { IsDisabled, IsEnabled };
|
|||||||
# define NO_UNIQUE_ADDRESS
|
# define NO_UNIQUE_ADDRESS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using ArgumentsString = StaticString<3700>;
|
using ArgumentsString = StaticString;
|
||||||
|
|
||||||
namespace Literals {
|
namespace Literals {
|
||||||
struct TracerLiteral
|
struct TracerLiteral
|
||||||
@@ -98,9 +98,7 @@ template<std::size_t size, typename Tuple>
|
|||||||
concept HasTupleSize = requires { std::tuple_size_v<Tuple> == size; };
|
concept HasTupleSize = requires { std::tuple_size_v<Tuple> == size; };
|
||||||
|
|
||||||
template<typename Entry>
|
template<typename Entry>
|
||||||
concept CanConvert = requires(Entry entry, StaticString<1000> string) {
|
concept CanConvert = requires(Entry entry, StaticString string) { convertToString(string, entry); };
|
||||||
convertToString(string, entry);
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
@@ -413,15 +411,11 @@ struct TraceEventWithoutArguments
|
|||||||
char type = ' ';
|
char type = ' ';
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename ArgumentsString>
|
struct alignas(4096) TraceEventWithArguments : public TraceEventWithoutArguments
|
||||||
struct alignas(4096) TraceEvent : public TraceEventWithoutArguments
|
|
||||||
{
|
{
|
||||||
using ArgumentsStringType = ArgumentsString;
|
|
||||||
|
|
||||||
ArgumentsString arguments;
|
ArgumentsString arguments;
|
||||||
};
|
};
|
||||||
|
|
||||||
using StringViewWithStringArgumentsTraceEvent = TraceEvent<ArgumentsString>;
|
|
||||||
|
|
||||||
enum class IsEnabled { No, Yes };
|
enum class IsEnabled { No, Yes };
|
||||||
|
|
||||||
@@ -431,12 +425,13 @@ class EventQueue;
|
|||||||
template<typename TraceEvent>
|
template<typename TraceEvent>
|
||||||
using EnabledEventQueue = EventQueue<TraceEvent, Tracing::IsEnabled>;
|
using EnabledEventQueue = EventQueue<TraceEvent, Tracing::IsEnabled>;
|
||||||
|
|
||||||
using EnabledEventQueueWithoutArguments = EventQueue<TraceEventWithoutArguments, Tracing::IsEnabled>;
|
using EnabledEventQueueWithArguments = EnabledEventQueue<TraceEventWithArguments>;
|
||||||
|
|
||||||
|
using EnabledEventQueueWithoutArguments = EnabledEventQueue<TraceEventWithoutArguments>;
|
||||||
|
|
||||||
template<typename TraceEvent>
|
template<typename TraceEvent>
|
||||||
void flushInThread(EnabledEventQueue<TraceEvent> &eventQueue);
|
void flushInThread(EnabledEventQueue<TraceEvent> &eventQueue);
|
||||||
extern template NANOTRACE_EXPORT void flushInThread(
|
extern template NANOTRACE_EXPORT void flushInThread(EnabledEventQueue<TraceEventWithArguments> &eventQueue);
|
||||||
EnabledEventQueue<StringViewWithStringArgumentsTraceEvent> &eventQueue);
|
|
||||||
extern template NANOTRACE_EXPORT void flushInThread(
|
extern template NANOTRACE_EXPORT void flushInThread(
|
||||||
EnabledEventQueue<TraceEventWithoutArguments> &eventQueue);
|
EnabledEventQueue<TraceEventWithoutArguments> &eventQueue);
|
||||||
|
|
||||||
@@ -598,13 +593,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<Tracing isEnabled>
|
template<Tracing isEnabled>
|
||||||
using StringViewWithStringArgumentsEventQueue = EventQueue<StringViewWithStringArgumentsTraceEvent, isEnabled>;
|
using EventQueueWithArguments = EventQueue<TraceEventWithArguments, isEnabled>;
|
||||||
|
|
||||||
template<Tracing isEnabled>
|
template<Tracing isEnabled>
|
||||||
using EventQueueWithoutArguments = EventQueue<TraceEventWithoutArguments, isEnabled>;
|
using EventQueueWithoutArguments = EventQueue<TraceEventWithoutArguments, isEnabled>;
|
||||||
|
using EnabledEventQueueWithoutArguments = EventQueueWithoutArguments<Tracing::IsEnabled>;
|
||||||
|
|
||||||
extern template class NANOTRACE_EXPORT_EXTERN_TEMPLATE
|
extern template class NANOTRACE_EXPORT_EXTERN_TEMPLATE EventQueue<TraceEventWithArguments, Tracing::IsEnabled>;
|
||||||
EventQueue<StringViewWithStringArgumentsTraceEvent, Tracing::IsEnabled>;
|
|
||||||
extern template class NANOTRACE_EXPORT_EXTERN_TEMPLATE
|
extern template class NANOTRACE_EXPORT_EXTERN_TEMPLATE
|
||||||
EventQueue<TraceEventWithoutArguments, Tracing::IsEnabled>;
|
EventQueue<TraceEventWithoutArguments, Tracing::IsEnabled>;
|
||||||
|
|
||||||
@@ -656,7 +650,171 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename Category, typename IsActive>
|
template<typename Category, typename IsActive>
|
||||||
class Tracer;
|
class Tracer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Tracer() = default;
|
||||||
|
using TokenType = typename Category::TokenType;
|
||||||
|
using FlowTokenType = typename Category::FlowTokenType;
|
||||||
|
|
||||||
|
friend TokenType;
|
||||||
|
friend FlowTokenType;
|
||||||
|
friend Category;
|
||||||
|
|
||||||
|
[[nodiscard]] Tracer(TracerLiteral, const Category &, KeyValue auto &&...) {}
|
||||||
|
|
||||||
|
Tracer(const Tracer &) = delete;
|
||||||
|
Tracer &operator=(const Tracer &) = delete;
|
||||||
|
Tracer(Tracer &&other) noexcept = default;
|
||||||
|
Tracer &operator=(Tracer &&other) noexcept = delete;
|
||||||
|
|
||||||
|
TokenType createToken() { return {}; }
|
||||||
|
|
||||||
|
Tracer beginDuration(TracerLiteral, KeyValue auto &&...) { return {}; }
|
||||||
|
|
||||||
|
void tick(TracerLiteral, KeyValue auto &&...) {}
|
||||||
|
|
||||||
|
void end(KeyValue auto &&...) {}
|
||||||
|
|
||||||
|
~Tracer() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Category>
|
||||||
|
class Tracer<Category, std::true_type>
|
||||||
|
{
|
||||||
|
using TokenType = typename Category::TokenType;
|
||||||
|
using FlowTokenType = typename Category::FlowTokenType;
|
||||||
|
using PrivateTag = typename Category::PrivateTag;
|
||||||
|
using CategoryFunctionPointer = typename Category::CategoryFunctionPointer;
|
||||||
|
|
||||||
|
friend FlowTokenType;
|
||||||
|
friend TokenType;
|
||||||
|
friend Category;
|
||||||
|
|
||||||
|
template<KeyValue... Arguments>
|
||||||
|
[[nodiscard]] Tracer(std::size_t bindId,
|
||||||
|
IsFlow flow,
|
||||||
|
TracerLiteral name,
|
||||||
|
CategoryFunctionPointer category,
|
||||||
|
Arguments &&...arguments)
|
||||||
|
: m_name{name}
|
||||||
|
, m_bindId{bindId}
|
||||||
|
, flow{flow}
|
||||||
|
, m_category{category}
|
||||||
|
{
|
||||||
|
if (category().isEnabled == IsEnabled::Yes)
|
||||||
|
sendBeginTrace(std::forward<Arguments>(arguments)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
template<KeyValue... Arguments>
|
||||||
|
[[nodiscard]] Tracer(PrivateTag,
|
||||||
|
std::size_t bindId,
|
||||||
|
IsFlow flow,
|
||||||
|
TracerLiteral name,
|
||||||
|
CategoryFunctionPointer category,
|
||||||
|
Arguments &&...arguments)
|
||||||
|
: Tracer{bindId, flow, std::move(name), category, std::forward<Arguments>(arguments)...}
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<KeyValue... Arguments>
|
||||||
|
[[nodiscard]] Tracer(TracerLiteral name, CategoryFunctionPointer category, Arguments &&...arguments)
|
||||||
|
: m_name{name}
|
||||||
|
, m_category{category}
|
||||||
|
{
|
||||||
|
if (category().isEnabled == IsEnabled::Yes)
|
||||||
|
sendBeginTrace(std::forward<Arguments>(arguments)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<KeyValue... Arguments>
|
||||||
|
[[nodiscard]] Tracer(TracerLiteral name, Category &category, Arguments &&...arguments)
|
||||||
|
: Tracer(std::move(name), category.self(), std::forward<Arguments>(arguments)...)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Tracer(const Tracer &) = delete;
|
||||||
|
Tracer &operator=(const Tracer &) = delete;
|
||||||
|
Tracer(Tracer &&other) noexcept = delete;
|
||||||
|
Tracer &operator=(Tracer &&other) noexcept = delete;
|
||||||
|
|
||||||
|
TokenType createToken() { return {0, m_category}; }
|
||||||
|
|
||||||
|
~Tracer() { sendEndTrace(); }
|
||||||
|
|
||||||
|
template<KeyValue... Arguments>
|
||||||
|
Tracer beginDuration(TracerLiteral name, Arguments &&...arguments)
|
||||||
|
{
|
||||||
|
return {std::move(name), m_category, std::forward<Arguments>(arguments)...};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<KeyValue... Arguments>
|
||||||
|
void tick(TracerLiteral name, Arguments &&...arguments)
|
||||||
|
{
|
||||||
|
m_category().begin('i', 0, name, 0, IsFlow::No, std::forward<Arguments>(arguments)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<KeyValue... Arguments>
|
||||||
|
void end(Arguments &&...arguments)
|
||||||
|
{
|
||||||
|
sendEndTrace(std::forward<Arguments>(arguments)...);
|
||||||
|
m_name = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
template<KeyValue... Arguments>
|
||||||
|
void sendBeginTrace(Arguments &&...arguments)
|
||||||
|
{
|
||||||
|
auto &category = m_category();
|
||||||
|
if (category.isEnabled == IsEnabled::Yes) {
|
||||||
|
auto &traceEvent = getTraceEvent(category.eventQueue(arguments...));
|
||||||
|
traceEvent.name = m_name;
|
||||||
|
traceEvent.category = category.name();
|
||||||
|
traceEvent.bindId = m_bindId;
|
||||||
|
traceEvent.flow = flow;
|
||||||
|
traceEvent.type = 'B';
|
||||||
|
if constexpr (sizeof...(arguments)) {
|
||||||
|
Internal::setArguments<ArgumentsString>(traceEvent.arguments,
|
||||||
|
std::forward<Arguments>(arguments)...);
|
||||||
|
}
|
||||||
|
traceEvent.time = Clock::now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<KeyValue... Arguments>
|
||||||
|
void sendEndTrace(Arguments &&...arguments)
|
||||||
|
{
|
||||||
|
if (m_name.size()) {
|
||||||
|
auto &category = m_category();
|
||||||
|
if (category.isEnabled == IsEnabled::Yes) {
|
||||||
|
auto end = Clock::now();
|
||||||
|
auto &traceEvent = getTraceEvent(category.eventQueue(arguments...));
|
||||||
|
traceEvent.name = std::move(m_name);
|
||||||
|
traceEvent.category = category.name();
|
||||||
|
traceEvent.time = end;
|
||||||
|
traceEvent.bindId = m_bindId;
|
||||||
|
traceEvent.flow = flow;
|
||||||
|
traceEvent.type = 'E';
|
||||||
|
if constexpr (sizeof...(arguments)) {
|
||||||
|
Internal::setArguments<ArgumentsString>(traceEvent.arguments,
|
||||||
|
std::forward<Arguments>(arguments)...);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string_view m_name;
|
||||||
|
std::size_t m_bindId = 0;
|
||||||
|
IsFlow flow = IsFlow::No;
|
||||||
|
CategoryFunctionPointer m_category;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Category, KeyValue... Arguments>
|
||||||
|
Tracer(TracerLiteral name, Category &category, Arguments &&...)
|
||||||
|
-> Tracer<Category, typename Category::IsActive>;
|
||||||
|
|
||||||
|
template<typename Category, KeyValue... Arguments>
|
||||||
|
Tracer(TracerLiteral name, const Category &category, Arguments &&...)
|
||||||
|
-> Tracer<Category, typename Category::IsActive>;
|
||||||
|
|
||||||
template<typename Category, Tracing isEnabled>
|
template<typename Category, Tracing isEnabled>
|
||||||
class Token : public BasicDisabledToken
|
class Token : public BasicDisabledToken
|
||||||
@@ -1130,8 +1288,7 @@ private:
|
|||||||
CategoryFunctionPointer m_category = nullptr;
|
CategoryFunctionPointer m_category = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename TraceEvent, Tracing isEnabled>
|
class DisabledCategory
|
||||||
class Category
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class SourceLocation
|
class SourceLocation
|
||||||
@@ -1143,21 +1300,22 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
using IsActive = std::false_type;
|
using IsActive = std::false_type;
|
||||||
using ArgumentsStringType = typename TraceEvent::ArgumentsStringType;
|
using AsynchronousTokenType = AsynchronousToken<DisabledCategory, Tracing::IsDisabled>;
|
||||||
using AsynchronousTokenType = AsynchronousToken<Category, Tracing::IsDisabled>;
|
using FlowTokenType = FlowToken<DisabledCategory, Tracing::IsDisabled>;
|
||||||
using FlowTokenType = FlowToken<Category, Tracing::IsDisabled>;
|
using TracerType = Tracer<DisabledCategory, std::false_type>;
|
||||||
using TracerType = Tracer<Category, std::false_type>;
|
using TokenType = Token<DisabledCategory, Tracing::IsDisabled>;
|
||||||
using TokenType = Token<Category, Tracing::IsDisabled>;
|
using CategoryFunctionPointer = DisabledCategory &(*) ();
|
||||||
using CategoryFunctionPointer = Category &(*) ();
|
|
||||||
|
|
||||||
Category(TracerLiteral,
|
DisabledCategory() = default;
|
||||||
EventQueue<TraceEvent, Tracing::IsDisabled> &,
|
|
||||||
|
DisabledCategory(TracerLiteral,
|
||||||
|
EventQueueWithArguments<Tracing::IsDisabled> &,
|
||||||
EventQueueWithoutArguments<Tracing::IsDisabled> &,
|
EventQueueWithoutArguments<Tracing::IsDisabled> &,
|
||||||
CategoryFunctionPointer)
|
CategoryFunctionPointer)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Category(TracerLiteral,
|
DisabledCategory(TracerLiteral,
|
||||||
EventQueue<TraceEvent, Tracing::IsEnabled> &,
|
EventQueueWithArguments<Tracing::IsEnabled> &,
|
||||||
EventQueueWithoutArguments<Tracing::IsEnabled> &,
|
EventQueueWithoutArguments<Tracing::IsEnabled> &,
|
||||||
CategoryFunctionPointer)
|
CategoryFunctionPointer)
|
||||||
{}
|
{}
|
||||||
@@ -1171,7 +1329,9 @@ public:
|
|||||||
template<typename... Arguments>
|
template<typename... Arguments>
|
||||||
[[nodiscard]] std::pair<AsynchronousTokenType, FlowTokenType> beginAsynchronousWithFlow(
|
[[nodiscard]] std::pair<AsynchronousTokenType, FlowTokenType> beginAsynchronousWithFlow(
|
||||||
TracerLiteral, Arguments &&...)
|
TracerLiteral, Arguments &&...)
|
||||||
{}
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... Arguments>
|
template<typename... Arguments>
|
||||||
[[nodiscard]] TracerType beginDuration(TracerLiteral, Arguments &&...)
|
[[nodiscard]] TracerType beginDuration(TracerLiteral, Arguments &&...)
|
||||||
@@ -1193,8 +1353,7 @@ public:
|
|||||||
static constexpr bool isActive() { return false; }
|
static constexpr bool isActive() { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename TraceEvent>
|
class EnabledCategory
|
||||||
class Category<TraceEvent, Tracing::IsEnabled>
|
|
||||||
{
|
{
|
||||||
class PrivateTag
|
class PrivateTag
|
||||||
{};
|
{};
|
||||||
@@ -1233,12 +1392,11 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
using IsActive = std::true_type;
|
using IsActive = std::true_type;
|
||||||
using ArgumentsStringType = typename TraceEvent::ArgumentsStringType;
|
using AsynchronousTokenType = AsynchronousToken<EnabledCategory, Tracing::IsEnabled>;
|
||||||
using AsynchronousTokenType = AsynchronousToken<Category, Tracing::IsEnabled>;
|
using FlowTokenType = FlowToken<EnabledCategory, Tracing::IsEnabled>;
|
||||||
using FlowTokenType = FlowToken<Category, Tracing::IsEnabled>;
|
using TracerType = Tracer<EnabledCategory, std::true_type>;
|
||||||
using TracerType = Tracer<Category, std::true_type>;
|
using TokenType = Token<EnabledCategory, Tracing::IsEnabled>;
|
||||||
using TokenType = Token<Category, Tracing::IsEnabled>;
|
using CategoryFunctionPointer = EnabledCategory &(*) ();
|
||||||
using CategoryFunctionPointer = Category &(*) ();
|
|
||||||
|
|
||||||
friend AsynchronousTokenType;
|
friend AsynchronousTokenType;
|
||||||
friend TokenType;
|
friend TokenType;
|
||||||
@@ -1246,7 +1404,7 @@ public:
|
|||||||
friend TracerType;
|
friend TracerType;
|
||||||
|
|
||||||
template<typename EventQueue>
|
template<typename EventQueue>
|
||||||
Category(TracerLiteral name,
|
EnabledCategory(TracerLiteral name,
|
||||||
EventQueue &queue,
|
EventQueue &queue,
|
||||||
EnabledEventQueueWithoutArguments &eventQueueWithoutArguments,
|
EnabledEventQueueWithoutArguments &eventQueueWithoutArguments,
|
||||||
CategoryFunctionPointer self)
|
CategoryFunctionPointer self)
|
||||||
@@ -1261,8 +1419,8 @@ public:
|
|||||||
m_bindIdCounter = m_globalBindIdCounter += 1ULL << 32;
|
m_bindIdCounter = m_globalBindIdCounter += 1ULL << 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
Category(const Category &) = delete;
|
EnabledCategory(const EnabledCategory &) = delete;
|
||||||
Category &operator=(const Category &) = delete;
|
EnabledCategory &operator=(const EnabledCategory &) = delete;
|
||||||
|
|
||||||
template<typename... Arguments>
|
template<typename... Arguments>
|
||||||
[[nodiscard]] AsynchronousTokenType beginAsynchronous(TracerLiteral traceName,
|
[[nodiscard]] AsynchronousTokenType beginAsynchronous(TracerLiteral traceName,
|
||||||
@@ -1292,7 +1450,7 @@ public:
|
|||||||
template<typename... Arguments>
|
template<typename... Arguments>
|
||||||
[[nodiscard]] TracerType beginDuration(TracerLiteral traceName, Arguments &&...arguments)
|
[[nodiscard]] TracerType beginDuration(TracerLiteral traceName, Arguments &&...arguments)
|
||||||
{
|
{
|
||||||
return {traceName, m_self, std::forward<Arguments>(arguments)...};
|
return TracerType{traceName, m_self, std::forward<Arguments>(arguments)...};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Arguments>
|
template<typename... Arguments>
|
||||||
@@ -1333,7 +1491,7 @@ public:
|
|||||||
EnabledEventQueueWithoutArguments &eventQueue() const { return m_eventQueueWithoutArguments; }
|
EnabledEventQueueWithoutArguments &eventQueue() const { return m_eventQueueWithoutArguments; }
|
||||||
|
|
||||||
template<typename Arguments>
|
template<typename Arguments>
|
||||||
EnabledEventQueue<TraceEvent> &eventQueue(const Arguments &...) const
|
EnabledEventQueueWithArguments &eventQueue(const Arguments &...) const
|
||||||
{
|
{
|
||||||
return m_eventQueue;
|
return m_eventQueue;
|
||||||
}
|
}
|
||||||
@@ -1425,7 +1583,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::string_view m_name;
|
std::string_view m_name;
|
||||||
EnabledEventQueue<TraceEvent> &m_eventQueue;
|
EnabledEventQueueWithArguments &m_eventQueue;
|
||||||
EnabledEventQueueWithoutArguments &m_eventQueueWithoutArguments;
|
EnabledEventQueueWithoutArguments &m_eventQueueWithoutArguments;
|
||||||
inline static std::atomic<std::size_t> m_globalIdCounter;
|
inline static std::atomic<std::size_t> m_globalIdCounter;
|
||||||
std::size_t m_idCounter;
|
std::size_t m_idCounter;
|
||||||
@@ -1434,171 +1592,4 @@ private:
|
|||||||
CategoryFunctionPointer m_self;
|
CategoryFunctionPointer m_self;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Tracing isEnabled>
|
|
||||||
using StringViewWithStringArgumentsCategory = Category<StringViewWithStringArgumentsTraceEvent, isEnabled>;
|
|
||||||
|
|
||||||
template<typename Category, typename IsActive>
|
|
||||||
class Tracer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Tracer() = default;
|
|
||||||
using TokenType = typename Category::TokenType;
|
|
||||||
using FlowTokenType = typename Category::FlowTokenType;
|
|
||||||
|
|
||||||
friend TokenType;
|
|
||||||
friend FlowTokenType;
|
|
||||||
friend Category;
|
|
||||||
|
|
||||||
[[nodiscard]] Tracer(TracerLiteral, Category &, KeyValue auto &&...) {}
|
|
||||||
|
|
||||||
Tracer(const Tracer &) = delete;
|
|
||||||
Tracer &operator=(const Tracer &) = delete;
|
|
||||||
Tracer(Tracer &&other) noexcept = default;
|
|
||||||
Tracer &operator=(Tracer &&other) noexcept = delete;
|
|
||||||
|
|
||||||
TokenType createToken() { return {}; }
|
|
||||||
|
|
||||||
Tracer beginDuration(TracerLiteral, KeyValue auto &&...) { return {}; }
|
|
||||||
|
|
||||||
void tick(TracerLiteral, KeyValue auto &&...) {}
|
|
||||||
|
|
||||||
void end(KeyValue auto &&...) {}
|
|
||||||
|
|
||||||
~Tracer() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename Category>
|
|
||||||
class Tracer<Category, std::true_type>
|
|
||||||
{
|
|
||||||
using ArgumentsStringType = typename Category::ArgumentsStringType;
|
|
||||||
using TokenType = typename Category::TokenType;
|
|
||||||
using FlowTokenType = typename Category::FlowTokenType;
|
|
||||||
using PrivateTag = typename Category::PrivateTag;
|
|
||||||
using CategoryFunctionPointer = typename Category::CategoryFunctionPointer;
|
|
||||||
|
|
||||||
friend FlowTokenType;
|
|
||||||
friend TokenType;
|
|
||||||
friend Category;
|
|
||||||
|
|
||||||
template<KeyValue... Arguments>
|
|
||||||
[[nodiscard]] Tracer(std::size_t bindId,
|
|
||||||
IsFlow flow,
|
|
||||||
TracerLiteral name,
|
|
||||||
CategoryFunctionPointer category,
|
|
||||||
Arguments &&...arguments)
|
|
||||||
: m_name{name}
|
|
||||||
, m_bindId{bindId}
|
|
||||||
, flow{flow}
|
|
||||||
, m_category{category}
|
|
||||||
{
|
|
||||||
if (category().isEnabled == IsEnabled::Yes)
|
|
||||||
sendBeginTrace(std::forward<Arguments>(arguments)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
template<KeyValue... Arguments>
|
|
||||||
[[nodiscard]] Tracer(PrivateTag,
|
|
||||||
std::size_t bindId,
|
|
||||||
IsFlow flow,
|
|
||||||
TracerLiteral name,
|
|
||||||
CategoryFunctionPointer category,
|
|
||||||
Arguments &&...arguments)
|
|
||||||
: Tracer{bindId, flow, std::move(name), category, std::forward<Arguments>(arguments)...}
|
|
||||||
{}
|
|
||||||
|
|
||||||
template<KeyValue... Arguments>
|
|
||||||
[[nodiscard]] Tracer(TracerLiteral name, CategoryFunctionPointer category, Arguments &&...arguments)
|
|
||||||
: m_name{name}
|
|
||||||
, m_category{category}
|
|
||||||
{
|
|
||||||
if (category().isEnabled == IsEnabled::Yes)
|
|
||||||
sendBeginTrace(std::forward<Arguments>(arguments)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<KeyValue... Arguments>
|
|
||||||
[[nodiscard]] Tracer(TracerLiteral name, Category &category, Arguments &&...arguments)
|
|
||||||
: Tracer(std::move(name), category.self(), std::forward<Arguments>(arguments)...)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Tracer(const Tracer &) = delete;
|
|
||||||
Tracer &operator=(const Tracer &) = delete;
|
|
||||||
Tracer(Tracer &&other) noexcept = delete;
|
|
||||||
Tracer &operator=(Tracer &&other) noexcept = delete;
|
|
||||||
|
|
||||||
TokenType createToken() { return {0, m_category}; }
|
|
||||||
|
|
||||||
~Tracer() { sendEndTrace(); }
|
|
||||||
|
|
||||||
template<KeyValue... Arguments>
|
|
||||||
Tracer beginDuration(TracerLiteral name, Arguments &&...arguments)
|
|
||||||
{
|
|
||||||
return {std::move(name), m_category, std::forward<Arguments>(arguments)...};
|
|
||||||
}
|
|
||||||
|
|
||||||
template<KeyValue... Arguments>
|
|
||||||
void tick(TracerLiteral name, Arguments &&...arguments)
|
|
||||||
{
|
|
||||||
m_category().begin('i', 0, name, 0, IsFlow::No, std::forward<Arguments>(arguments)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<KeyValue... Arguments>
|
|
||||||
void end(Arguments &&...arguments)
|
|
||||||
{
|
|
||||||
sendEndTrace(std::forward<Arguments>(arguments)...);
|
|
||||||
m_name = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
template<KeyValue... Arguments>
|
|
||||||
void sendBeginTrace(Arguments &&...arguments)
|
|
||||||
{
|
|
||||||
auto &category = m_category();
|
|
||||||
if (category.isEnabled == IsEnabled::Yes) {
|
|
||||||
auto &traceEvent = getTraceEvent(category.eventQueue(arguments...));
|
|
||||||
traceEvent.name = m_name;
|
|
||||||
traceEvent.category = category.name();
|
|
||||||
traceEvent.bindId = m_bindId;
|
|
||||||
traceEvent.flow = flow;
|
|
||||||
traceEvent.type = 'B';
|
|
||||||
if constexpr (sizeof...(arguments)) {
|
|
||||||
Internal::setArguments<ArgumentsStringType>(traceEvent.arguments,
|
|
||||||
std::forward<Arguments>(arguments)...);
|
|
||||||
}
|
|
||||||
traceEvent.time = Clock::now();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<KeyValue... Arguments>
|
|
||||||
void sendEndTrace(Arguments &&...arguments)
|
|
||||||
{
|
|
||||||
if (m_name.size()) {
|
|
||||||
auto &category = m_category();
|
|
||||||
if (category.isEnabled == IsEnabled::Yes) {
|
|
||||||
auto end = Clock::now();
|
|
||||||
auto &traceEvent = getTraceEvent(category.eventQueue(arguments...));
|
|
||||||
traceEvent.name = std::move(m_name);
|
|
||||||
traceEvent.category = category.name();
|
|
||||||
traceEvent.time = end;
|
|
||||||
traceEvent.bindId = m_bindId;
|
|
||||||
traceEvent.flow = flow;
|
|
||||||
traceEvent.type = 'E';
|
|
||||||
if constexpr (sizeof...(arguments)) {
|
|
||||||
Internal::setArguments<ArgumentsStringType>(traceEvent.arguments,
|
|
||||||
std::forward<Arguments>(arguments)...);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string_view m_name;
|
|
||||||
std::size_t m_bindId = 0;
|
|
||||||
IsFlow flow = IsFlow::No;
|
|
||||||
CategoryFunctionPointer m_category;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename Category, KeyValue... Arguments>
|
|
||||||
Tracer(TracerLiteral name, Category &category, Arguments &&...)
|
|
||||||
-> Tracer<Category, typename Category::IsActive>;
|
|
||||||
|
|
||||||
} // namespace NanotraceHR
|
} // namespace NanotraceHR
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace NanotraceHR {
|
namespace NanotraceHR {
|
||||||
|
|
||||||
template<std::size_t Capacity>
|
|
||||||
class StaticString
|
class StaticString
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -27,13 +26,13 @@ public:
|
|||||||
{
|
{
|
||||||
auto newSize = m_size + string.size();
|
auto newSize = m_size + string.size();
|
||||||
|
|
||||||
if (newSize <= Capacity) {
|
if (newSize <= capacity) {
|
||||||
std::char_traits<char>::copy(std::next(data(), static_cast<std::ptrdiff_t>(m_size)),
|
std::char_traits<char>::copy(std::next(data(), static_cast<std::ptrdiff_t>(m_size)),
|
||||||
string.data(),
|
string.data(),
|
||||||
string.size());
|
string.size());
|
||||||
m_size = newSize;
|
m_size = newSize;
|
||||||
} else {
|
} else {
|
||||||
m_size = Capacity + 1;
|
m_size = capacity + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,13 +40,13 @@ public:
|
|||||||
{
|
{
|
||||||
auto newSize = m_size + 1;
|
auto newSize = m_size + 1;
|
||||||
|
|
||||||
if (newSize <= Capacity) {
|
if (newSize <= capacity) {
|
||||||
auto current = std::next(data(), static_cast<std::ptrdiff_t>(m_size));
|
auto current = std::next(data(), static_cast<std::ptrdiff_t>(m_size));
|
||||||
*current = character;
|
*current = character;
|
||||||
|
|
||||||
m_size = newSize;
|
m_size = newSize;
|
||||||
} else {
|
} else {
|
||||||
m_size = Capacity + 1;
|
m_size = capacity + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +102,7 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isValid() const { return m_size <= Capacity; }
|
constexpr bool isValid() const { return m_size <= capacity; }
|
||||||
|
|
||||||
std::size_t size() const { return m_size; }
|
std::size_t size() const { return m_size; }
|
||||||
|
|
||||||
@@ -115,7 +114,8 @@ public:
|
|||||||
void clear() { m_size = 0; }
|
void clear() { m_size = 0; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<char, Capacity> m_data;
|
inline static constexpr std::size_t capacity = 3700;
|
||||||
|
std::array<char, capacity> m_data;
|
||||||
std::size_t m_size = 0;
|
std::size_t m_size = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
namespace Sqlite {
|
namespace Sqlite {
|
||||||
|
|
||||||
|
#ifdef ENABLE_SQLITE_TRACING
|
||||||
|
|
||||||
std::shared_ptr<TraceFile> traceFile()
|
std::shared_ptr<TraceFile> traceFile()
|
||||||
{
|
{
|
||||||
static auto traceFile = std::make_shared<TraceFile>("tracing.json");
|
static auto traceFile = std::make_shared<TraceFile>("tracing.json");
|
||||||
@@ -14,27 +16,23 @@ std::shared_ptr<TraceFile> traceFile()
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
thread_local NanotraceHR::StringViewWithStringArgumentsEventQueue<sqliteTracingStatus()> eventQueue(
|
thread_local NanotraceHR::EnabledEventQueueWithoutArguments eventQueue(traceFile());
|
||||||
traceFile());
|
thread_local NanotraceHR::EnabledEventQueueWithoutArguments eventQueueWithoutArguments(traceFile());
|
||||||
thread_local NanotraceHR::EventQueueWithoutArguments<sqliteTracingStatus()> eventQueueWithoutArguments(
|
|
||||||
traceFile());
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NanotraceHR::StringViewWithStringArgumentsCategory<sqliteTracingStatus()> &sqliteLowLevelCategory()
|
NanotraceHR::EnabledCategory &sqliteLowLevelCategory()
|
||||||
{
|
{
|
||||||
thread_local NanotraceHR::StringViewWithStringArgumentsCategory<sqliteTracingStatus()>
|
thread_local NanotraceHR::EnabledCategory sqliteLowLevelCategory_{"sqlite low level",
|
||||||
sqliteLowLevelCategory_{"sqlite low level",
|
|
||||||
eventQueue,
|
eventQueue,
|
||||||
eventQueueWithoutArguments,
|
eventQueueWithoutArguments,
|
||||||
sqliteLowLevelCategory};
|
sqliteLowLevelCategory};
|
||||||
return sqliteLowLevelCategory_;
|
return sqliteLowLevelCategory_;
|
||||||
}
|
}
|
||||||
|
|
||||||
NanotraceHR::StringViewWithStringArgumentsCategory<sqliteTracingStatus()> &sqliteHighLevelCategory()
|
NanotraceHR::EnabledCategory &sqliteHighLevelCategory()
|
||||||
{
|
{
|
||||||
thread_local NanotraceHR::StringViewWithStringArgumentsCategory<sqliteTracingStatus()>
|
thread_local NanotraceHR::EnabledCategory sqliteHighLevelCategory_{"sqlite high level",
|
||||||
sqliteHighLevelCategory_{"sqlite high level",
|
|
||||||
eventQueue,
|
eventQueue,
|
||||||
eventQueueWithoutArguments,
|
eventQueueWithoutArguments,
|
||||||
sqliteHighLevelCategory};
|
sqliteHighLevelCategory};
|
||||||
@@ -42,4 +40,6 @@ NanotraceHR::StringViewWithStringArgumentsCategory<sqliteTracingStatus()> &sqlit
|
|||||||
return sqliteHighLevelCategory_;
|
return sqliteHighLevelCategory_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace Sqlite
|
} // namespace Sqlite
|
||||||
|
@@ -10,22 +10,25 @@
|
|||||||
namespace Sqlite {
|
namespace Sqlite {
|
||||||
using namespace NanotraceHR::Literals;
|
using namespace NanotraceHR::Literals;
|
||||||
|
|
||||||
constexpr NanotraceHR::Tracing sqliteTracingStatus()
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_SQLITE_TRACING
|
#ifdef ENABLE_SQLITE_TRACING
|
||||||
return NanotraceHR::Tracing::IsEnabled;
|
|
||||||
|
using TraceFile = NanotraceHR::EnabledTraceFile;
|
||||||
|
|
||||||
|
SQLITE_EXPORT std::shared_ptr<NanotraceHR::EnabledTraceFile> traceFile();
|
||||||
|
|
||||||
|
NanotraceHR::EnabledCategory &sqliteLowLevelCategory();
|
||||||
|
|
||||||
|
SQLITE_EXPORT NanotraceHR::EnabledCategory &sqliteHighLevelCategory();
|
||||||
#else
|
#else
|
||||||
return NanotraceHR::Tracing::IsDisabled;
|
inline NanotraceHR::DisabledCategory sqliteLowLevelCategory()
|
||||||
#endif
|
{
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
using TraceFile = NanotraceHR::TraceFile<sqliteTracingStatus()>;
|
inline NanotraceHR::DisabledCategory sqliteHighLevelCategory()
|
||||||
|
{
|
||||||
SQLITE_EXPORT std::shared_ptr<TraceFile> traceFile();
|
return {};
|
||||||
|
}
|
||||||
NanotraceHR::StringViewWithStringArgumentsCategory<sqliteTracingStatus()> &sqliteLowLevelCategory();
|
#endif
|
||||||
|
|
||||||
SQLITE_EXPORT NanotraceHR::StringViewWithStringArgumentsCategory<sqliteTracingStatus()> &
|
|
||||||
sqliteHighLevelCategory();
|
|
||||||
|
|
||||||
} // namespace Sqlite
|
} // namespace Sqlite
|
||||||
|
@@ -9,9 +9,12 @@
|
|||||||
|
|
||||||
namespace QmlDesigner::FormEditorTracing {
|
namespace QmlDesigner::FormEditorTracing {
|
||||||
using namespace NanotraceHR::Literals;
|
using namespace NanotraceHR::Literals;
|
||||||
|
|
||||||
|
#ifdef ENABLE_FORM_EDITOR_TRACING
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
thread_local Category category_{"model",
|
thread_local Category category_{"form editor",
|
||||||
Tracing::eventQueueWithStringArguments(),
|
Tracing::eventQueueWithStringArguments(),
|
||||||
Tracing::eventQueueWithoutArguments(),
|
Tracing::eventQueueWithoutArguments(),
|
||||||
category};
|
category};
|
||||||
@@ -23,4 +26,6 @@ Category &category()
|
|||||||
return category_;
|
return category_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace QmlDesigner::FormEditorTracing
|
} // namespace QmlDesigner::FormEditorTracing
|
||||||
|
@@ -9,18 +9,22 @@
|
|||||||
|
|
||||||
namespace QmlDesigner::FormEditorTracing {
|
namespace QmlDesigner::FormEditorTracing {
|
||||||
|
|
||||||
constexpr NanotraceHR::Tracing tracingStatus()
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_FORM_EDITOR_TRACING
|
#ifdef ENABLE_FORM_EDITOR_TRACING
|
||||||
return NanotraceHR::Tracing::IsEnabled;
|
|
||||||
#else
|
|
||||||
return NanotraceHR::Tracing::IsDisabled;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
using Category = NanotraceHR::StringViewWithStringArgumentsCategory<tracingStatus()>;
|
using Category = NanotraceHR::EnabledCategory;
|
||||||
using SourceLocation = Category::SourceLocation;
|
using SourceLocation = Category::SourceLocation;
|
||||||
|
|
||||||
[[gnu::pure]] QMLDESIGNERCOMPONENTS_EXPORT Category &category();
|
[[gnu::pure]] QMLDESIGNERCOMPONENTS_EXPORT Category &category();
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
using Category = NanotraceHR::DisabledCategory;
|
||||||
|
using SourceLocation = Category::SourceLocation;
|
||||||
|
|
||||||
|
inline Category category()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
} // namespace QmlDesigner::FormEditorTracing
|
} // namespace QmlDesigner::FormEditorTracing
|
||||||
|
@@ -9,9 +9,12 @@
|
|||||||
|
|
||||||
namespace QmlDesigner::ItemLibraryTracing {
|
namespace QmlDesigner::ItemLibraryTracing {
|
||||||
using namespace NanotraceHR::Literals;
|
using namespace NanotraceHR::Literals;
|
||||||
|
|
||||||
|
#ifdef ENABLE_ITEM_LIBRARY_TRACING
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
thread_local Category category_{"model",
|
thread_local Category category_{"item library",
|
||||||
Tracing::eventQueueWithStringArguments(),
|
Tracing::eventQueueWithStringArguments(),
|
||||||
Tracing::eventQueueWithoutArguments(),
|
Tracing::eventQueueWithoutArguments(),
|
||||||
category};
|
category};
|
||||||
@@ -23,4 +26,6 @@ Category &category()
|
|||||||
return category_;
|
return category_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace QmlDesigner::ItemLibraryTracing
|
} // namespace QmlDesigner::ItemLibraryTracing
|
||||||
|
@@ -9,18 +9,23 @@
|
|||||||
|
|
||||||
namespace QmlDesigner::ItemLibraryTracing {
|
namespace QmlDesigner::ItemLibraryTracing {
|
||||||
|
|
||||||
constexpr NanotraceHR::Tracing tracingStatus()
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_ITEM_LIBRARY_TRACING
|
#ifdef ENABLE_ITEM_LIBRARY_TRACING
|
||||||
return NanotraceHR::Tracing::IsEnabled;
|
|
||||||
#else
|
|
||||||
return NanotraceHR::Tracing::IsDisabled;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
using Category = NanotraceHR::StringViewWithStringArgumentsCategory<tracingStatus()>;
|
using Category = NanotraceHR::EnabledCategory;
|
||||||
using SourceLocation = Category::SourceLocation;
|
using SourceLocation = Category::SourceLocation;
|
||||||
|
|
||||||
[[gnu::pure]] QMLDESIGNERCOMPONENTS_EXPORT Category &category();
|
[[gnu::pure]] QMLDESIGNERCOMPONENTS_EXPORT Category &category();
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
using Category = NanotraceHR::DisabledCategory;
|
||||||
|
using SourceLocation = Category::SourceLocation;
|
||||||
|
|
||||||
|
inline Category category()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace QmlDesigner::ItemLibraryTracing
|
} // namespace QmlDesigner::ItemLibraryTracing
|
||||||
|
@@ -9,9 +9,12 @@
|
|||||||
|
|
||||||
namespace QmlDesigner::NavigatorTracing {
|
namespace QmlDesigner::NavigatorTracing {
|
||||||
using namespace NanotraceHR::Literals;
|
using namespace NanotraceHR::Literals;
|
||||||
|
|
||||||
|
#ifdef ENABLE_NAVIGATOR_TRACING
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
thread_local Category category_{"model",
|
thread_local Category category_{"navigator",
|
||||||
Tracing::eventQueueWithStringArguments(),
|
Tracing::eventQueueWithStringArguments(),
|
||||||
Tracing::eventQueueWithoutArguments(),
|
Tracing::eventQueueWithoutArguments(),
|
||||||
category};
|
category};
|
||||||
@@ -23,4 +26,6 @@ Category &category()
|
|||||||
return category_;
|
return category_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace QmlDesigner::NavigatorTracing
|
} // namespace QmlDesigner::NavigatorTracing
|
||||||
|
@@ -9,18 +9,23 @@
|
|||||||
|
|
||||||
namespace QmlDesigner::NavigatorTracing {
|
namespace QmlDesigner::NavigatorTracing {
|
||||||
|
|
||||||
constexpr NanotraceHR::Tracing tracingStatus()
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_NAVIGATOR_TRACING
|
#ifdef ENABLE_NAVIGATOR_TRACING
|
||||||
return NanotraceHR::Tracing::IsEnabled;
|
|
||||||
#else
|
|
||||||
return NanotraceHR::Tracing::IsDisabled;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
using Category = NanotraceHR::StringViewWithStringArgumentsCategory<tracingStatus()>;
|
using Category = NanotraceHR::EnabledCategory;
|
||||||
using SourceLocation = Category::SourceLocation;
|
using SourceLocation = Category::SourceLocation;
|
||||||
|
|
||||||
[[gnu::pure]] QMLDESIGNERCOMPONENTS_EXPORT Category &category();
|
[[gnu::pure]] QMLDESIGNERCOMPONENTS_EXPORT Category &category();
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
using Category = NanotraceHR::DisabledCategory;
|
||||||
|
using SourceLocation = Category::SourceLocation;
|
||||||
|
|
||||||
|
inline Category category()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace QmlDesigner::NavigatorTracing
|
} // namespace QmlDesigner::NavigatorTracing
|
||||||
|
@@ -9,9 +9,12 @@
|
|||||||
|
|
||||||
namespace QmlDesigner::PropertyEditorTracing {
|
namespace QmlDesigner::PropertyEditorTracing {
|
||||||
using namespace NanotraceHR::Literals;
|
using namespace NanotraceHR::Literals;
|
||||||
|
|
||||||
|
#ifdef ENABLE_PROPERTY_EDITOR_TRACING
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
thread_local Category category_{"model",
|
thread_local Category category_{"property editor",
|
||||||
Tracing::eventQueueWithStringArguments(),
|
Tracing::eventQueueWithStringArguments(),
|
||||||
Tracing::eventQueueWithoutArguments(),
|
Tracing::eventQueueWithoutArguments(),
|
||||||
category};
|
category};
|
||||||
@@ -23,4 +26,6 @@ Category &category()
|
|||||||
return category_;
|
return category_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace QmlDesigner::PropertyEditorTracing
|
} // namespace QmlDesigner::PropertyEditorTracing
|
||||||
|
@@ -9,18 +9,23 @@
|
|||||||
|
|
||||||
namespace QmlDesigner::PropertyEditorTracing {
|
namespace QmlDesigner::PropertyEditorTracing {
|
||||||
|
|
||||||
constexpr NanotraceHR::Tracing tracingStatus()
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_PROPERTY_EDITOR_TRACING
|
#ifdef ENABLE_PROPERTY_EDITOR_TRACING
|
||||||
return NanotraceHR::Tracing::IsEnabled;
|
|
||||||
#else
|
|
||||||
return NanotraceHR::Tracing::IsDisabled;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
using Category = NanotraceHR::StringViewWithStringArgumentsCategory<tracingStatus()>;
|
using Category = NanotraceHR::EnabledCategory;
|
||||||
using SourceLocation = Category::SourceLocation;
|
using SourceLocation = Category::SourceLocation;
|
||||||
|
|
||||||
[[gnu::pure]] QMLDESIGNERCOMPONENTS_EXPORT Category &category();
|
[[gnu::pure]] QMLDESIGNERCOMPONENTS_EXPORT Category &category();
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
using Category = NanotraceHR::DisabledCategory;
|
||||||
|
using SourceLocation = Category::SourceLocation;
|
||||||
|
|
||||||
|
inline Category category()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace QmlDesigner::PropertyEditorTracing
|
} // namespace QmlDesigner::PropertyEditorTracing
|
||||||
|
@@ -18,6 +18,9 @@ namespace QmlDesigner {
|
|||||||
using namespace NanotraceHR::Literals;
|
using namespace NanotraceHR::Literals;
|
||||||
|
|
||||||
namespace ImageCache {
|
namespace ImageCache {
|
||||||
|
|
||||||
|
#ifdef ENABLE_IMAGE_CACHE_TRACING
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
thread_local Category category_{"image cache",
|
thread_local Category category_{"image cache",
|
||||||
@@ -30,6 +33,9 @@ Category &category()
|
|||||||
{
|
{
|
||||||
return category_;
|
return category_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace ImageCache
|
} // namespace ImageCache
|
||||||
|
|
||||||
AsynchronousImageCache::AsynchronousImageCache(ImageCacheStorageInterface &storage,
|
AsynchronousImageCache::AsynchronousImageCache(ImageCacheStorageInterface &storage,
|
||||||
|
@@ -17,20 +17,27 @@ namespace QmlDesigner {
|
|||||||
|
|
||||||
namespace ImageCache {
|
namespace ImageCache {
|
||||||
|
|
||||||
constexpr NanotraceHR::Tracing tracingStatus()
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_IMAGE_CACHE_TRACING
|
#ifdef ENABLE_IMAGE_CACHE_TRACING
|
||||||
return NanotraceHR::Tracing::IsEnabled;
|
|
||||||
#else
|
|
||||||
return NanotraceHR::Tracing::IsDisabled;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
using Category = NanotraceHR::StringViewWithStringArgumentsCategory<tracingStatus()>;
|
using Category = NanotraceHR::EnabledCategory;
|
||||||
using TraceToken = Category::FlowTokenType;
|
using TraceToken = Category::FlowTokenType;
|
||||||
using FlowToken = Category::FlowTokenType;
|
using FlowToken = Category::FlowTokenType;
|
||||||
using Token = Category::TokenType;
|
using Token = Category::TokenType;
|
||||||
extern Category &category();
|
[[gnu::pure]] QMLDESIGNERCORE_EXPORT Category &category();
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
using Category = NanotraceHR::DisabledCategory;
|
||||||
|
using TraceToken = Category::FlowTokenType;
|
||||||
|
using FlowToken = Category::FlowTokenType;
|
||||||
|
using Token = Category::TokenType;
|
||||||
|
|
||||||
|
inline Category category()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
class FontCollectorSizeAuxiliaryData
|
class FontCollectorSizeAuxiliaryData
|
||||||
{
|
{
|
||||||
|
@@ -11,10 +11,9 @@ using namespace NanotraceHR::Literals;
|
|||||||
using NanotraceHR::keyValue;
|
using NanotraceHR::keyValue;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
auto &category()
|
|
||||||
{
|
auto category = ProjectStorageTracing::projectStorageCategory;
|
||||||
return ProjectStorageTracing::projectStorageCategory();
|
|
||||||
}
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
TypeHasInvalidSourceId::TypeHasInvalidSourceId(const Sqlite::source_location &location)
|
TypeHasInvalidSourceId::TypeHasInvalidSourceId(const Sqlite::source_location &location)
|
||||||
|
@@ -9,34 +9,35 @@ namespace QmlDesigner {
|
|||||||
|
|
||||||
using namespace NanotraceHR::Literals;
|
using namespace NanotraceHR::Literals;
|
||||||
|
|
||||||
|
#ifdef ENABLE_QMLDESIGNER_TRACING
|
||||||
|
|
||||||
namespace Tracing {
|
namespace Tracing {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using TraceFile = NanotraceHR::TraceFile<tracingStatus()>;
|
using TraceFile = NanotraceHR::EnabledTraceFile;
|
||||||
|
|
||||||
auto traceFile()
|
auto traceFile()
|
||||||
{
|
{
|
||||||
if constexpr (std::is_same_v<Sqlite::TraceFile, TraceFile>) {
|
# ifdef ENABLE_SQLITE_TRACING
|
||||||
return Sqlite::traceFile();
|
return Sqlite::traceFile();
|
||||||
} else {
|
# else
|
||||||
static auto traceFile = std::make_shared<TraceFile>("tracing.json");
|
static auto traceFile = std::make_shared<TraceFile>("tracing.json");
|
||||||
return traceFile;
|
return traceFile;
|
||||||
}
|
# endif
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
EventQueueWithStringArguments &eventQueueWithStringArguments()
|
EventQueueWithStringArguments &eventQueueWithStringArguments()
|
||||||
{
|
{
|
||||||
thread_local NanotraceHR::StringViewWithStringArgumentsEventQueue<tracingStatus()> eventQueue(
|
thread_local NanotraceHR::EnabledEventQueueWithArguments eventQueue(traceFile());
|
||||||
traceFile());
|
|
||||||
|
|
||||||
return eventQueue;
|
return eventQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventQueueWithoutArguments &eventQueueWithoutArguments()
|
EventQueueWithoutArguments &eventQueueWithoutArguments()
|
||||||
{
|
{
|
||||||
thread_local NanotraceHR::EventQueueWithoutArguments<tracingStatus()> eventQueue(traceFile());
|
thread_local NanotraceHR::EnabledEventQueueWithoutArguments eventQueue(traceFile());
|
||||||
|
|
||||||
return eventQueue;
|
return eventQueue;
|
||||||
}
|
}
|
||||||
@@ -44,6 +45,9 @@ EventQueueWithoutArguments &eventQueueWithoutArguments()
|
|||||||
} // namespace Tracing
|
} // namespace Tracing
|
||||||
|
|
||||||
namespace ModelTracing {
|
namespace ModelTracing {
|
||||||
|
|
||||||
|
# ifdef ENABLE_MODEL_TRACING
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
thread_local Category category_{"model",
|
thread_local Category category_{"model",
|
||||||
@@ -58,10 +62,14 @@ Category &category()
|
|||||||
return category_;
|
return category_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
} // namespace ModelTracing
|
} // namespace ModelTracing
|
||||||
|
|
||||||
namespace ProjectStorageTracing {
|
namespace ProjectStorageTracing {
|
||||||
|
|
||||||
|
# ifdef ENABLE_PROJECT_STORAGE_TRACING
|
||||||
|
|
||||||
Category &projectStorageCategory()
|
Category &projectStorageCategory()
|
||||||
{
|
{
|
||||||
thread_local Category category{"project storage",
|
thread_local Category category{"project storage",
|
||||||
@@ -82,17 +90,28 @@ Category &projectStorageUpdaterCategory()
|
|||||||
return category;
|
return category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
} // namespace ProjectStorageTracing
|
} // namespace ProjectStorageTracing
|
||||||
|
|
||||||
namespace SourcePathStorageTracing {
|
namespace SourcePathStorageTracing {
|
||||||
|
|
||||||
|
# ifdef ENABLE_SOURCE_PATH_STORAGE_TRACING
|
||||||
|
|
||||||
Category &category()
|
Category &category()
|
||||||
{
|
{
|
||||||
thread_local Category category_{"project storage updater",
|
thread_local Category category_{"source path storage",
|
||||||
Tracing::eventQueueWithStringArguments(),
|
Tracing::eventQueueWithStringArguments(),
|
||||||
Tracing::eventQueueWithoutArguments(),
|
Tracing::eventQueueWithoutArguments(),
|
||||||
category};
|
category};
|
||||||
|
|
||||||
return category_;
|
return category_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
} // namespace SourcePathStorageTracing
|
} // namespace SourcePathStorageTracing
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -10,70 +10,87 @@
|
|||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
namespace Tracing {
|
namespace Tracing {
|
||||||
|
|
||||||
constexpr NanotraceHR::Tracing tracingStatus()
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_QMLDESIGNER_TRACING
|
#ifdef ENABLE_QMLDESIGNER_TRACING
|
||||||
return NanotraceHR::Tracing::IsEnabled;
|
|
||||||
#else
|
|
||||||
return NanotraceHR::Tracing::IsDisabled;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
using EventQueueWithStringArguments = NanotraceHR::StringViewWithStringArgumentsEventQueue<tracingStatus()>;
|
using EventQueueWithStringArguments = NanotraceHR::EnabledEventQueueWithArguments;
|
||||||
using EventQueueWithoutArguments = NanotraceHR::EventQueueWithoutArguments<tracingStatus()>;
|
using EventQueueWithoutArguments = NanotraceHR::EnabledEventQueueWithoutArguments;
|
||||||
|
|
||||||
[[gnu::pure]] QMLDESIGNERCORE_EXPORT EventQueueWithStringArguments &eventQueueWithStringArguments();
|
[[gnu::pure]] QMLDESIGNERCORE_EXPORT EventQueueWithStringArguments &eventQueueWithStringArguments();
|
||||||
[[gnu::pure]] QMLDESIGNERCORE_EXPORT EventQueueWithoutArguments &eventQueueWithoutArguments();
|
[[gnu::pure]] QMLDESIGNERCORE_EXPORT EventQueueWithoutArguments &eventQueueWithoutArguments();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace Tracing
|
} // namespace Tracing
|
||||||
|
|
||||||
namespace ModelTracing {
|
namespace ModelTracing {
|
||||||
constexpr NanotraceHR::Tracing tracingStatus()
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_MODEL_TRACING
|
|
||||||
return NanotraceHR::Tracing::IsEnabled;
|
|
||||||
#else
|
|
||||||
return NanotraceHR::Tracing::IsDisabled;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
using Category = NanotraceHR::StringViewWithStringArgumentsCategory<tracingStatus()>;
|
#ifdef ENABLE_MODEL_TRACING
|
||||||
|
|
||||||
|
using Category = NanotraceHR::EnabledCategory;
|
||||||
using SourceLocation = Category::SourceLocation;
|
using SourceLocation = Category::SourceLocation;
|
||||||
using AsynchronousToken = Category::AsynchronousTokenType;
|
using AsynchronousToken = Category::AsynchronousTokenType;
|
||||||
[[gnu::pure]] QMLDESIGNERCORE_EXPORT Category &category();
|
[[gnu::pure]] QMLDESIGNERCORE_EXPORT Category &category();
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
using Category = NanotraceHR::DisabledCategory;
|
||||||
|
using SourceLocation = Category::SourceLocation;
|
||||||
|
using AsynchronousToken = Category::AsynchronousTokenType;
|
||||||
|
|
||||||
|
inline Category category()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace ModelTracing
|
} // namespace ModelTracing
|
||||||
|
|
||||||
namespace ProjectStorageTracing {
|
namespace ProjectStorageTracing {
|
||||||
constexpr NanotraceHR::Tracing projectStorageTracingStatus()
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_PROJECT_STORAGE_TRACING
|
|
||||||
return NanotraceHR::Tracing::IsEnabled;
|
|
||||||
#else
|
|
||||||
return NanotraceHR::Tracing::IsDisabled;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
using Category = NanotraceHR::StringViewWithStringArgumentsCategory<projectStorageTracingStatus()>;
|
#ifdef ENABLE_PROJECT_STORAGE_TRACING
|
||||||
|
|
||||||
|
using Category = NanotraceHR::EnabledCategory;
|
||||||
|
|
||||||
[[gnu::pure]] Category &projectStorageCategory();
|
[[gnu::pure]] Category &projectStorageCategory();
|
||||||
|
|
||||||
[[gnu::pure]] Category &projectStorageUpdaterCategory();
|
[[gnu::pure]] Category &projectStorageUpdaterCategory();
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
using Category = NanotraceHR::DisabledCategory;
|
||||||
|
|
||||||
|
inline Category projectStorageCategory()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Category projectStorageUpdaterCategory()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace ProjectStorageTracing
|
} // namespace ProjectStorageTracing
|
||||||
|
|
||||||
namespace SourcePathStorageTracing {
|
namespace SourcePathStorageTracing {
|
||||||
constexpr NanotraceHR::Tracing tracingStatus()
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_SOURCE_PATH_STORAGE_TRACING
|
|
||||||
return NanotraceHR::Tracing::IsEnabled;
|
|
||||||
#else
|
|
||||||
return NanotraceHR::Tracing::IsDisabled;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
using Category = NanotraceHR::StringViewWithStringArgumentsCategory<tracingStatus()>;
|
#ifdef ENABLE_SOURCE_PATH_STORAGE_TRACING
|
||||||
|
|
||||||
|
using Category = NanotraceHR::EnabledCategory;
|
||||||
|
|
||||||
[[gnu::pure]] Category &category();
|
[[gnu::pure]] Category &category();
|
||||||
|
#else
|
||||||
|
|
||||||
|
using Category = NanotraceHR::DisabledCategory;
|
||||||
|
|
||||||
|
inline Category category()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace SourcePathStorageTracing
|
} // namespace SourcePathStorageTracing
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -26,7 +26,7 @@ auto IsTask(Matcher matcher)
|
|||||||
|
|
||||||
class TaskQueue : public testing::Test
|
class TaskQueue : public testing::Test
|
||||||
{
|
{
|
||||||
using Category = NanotraceHR::StringViewWithStringArgumentsCategory<NanotraceHR::Tracing::IsDisabled>;
|
using Category = NanotraceHR::DisabledCategory;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Notification notification;
|
Notification notification;
|
||||||
|
Reference in New Issue
Block a user