mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 19:16:56 +02:00
Further reduce cost of Duration class when tracing is inactive
This commit is contained in:
parent
99af7f2819
commit
694c8b5690
1 changed files with 8 additions and 4 deletions
|
@ -25,8 +25,12 @@ Q_LOGGING_CATEGORY(trace_simulation_physics, "trace.simulation.physics")
|
||||||
#define NSIGHT_TRACING
|
#define NSIGHT_TRACING
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool tracingEnabled() {
|
||||||
|
return DependencyManager::get<tracing::Tracer>()->isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
Duration::Duration(const QLoggingCategory& category, const QString& name, uint32_t argbColor, uint64_t payload, const QVariantMap& baseArgs) : _name(name), _category(category) {
|
Duration::Duration(const QLoggingCategory& category, const QString& name, uint32_t argbColor, uint64_t payload, const QVariantMap& baseArgs) : _name(name), _category(category) {
|
||||||
if (_category.isDebugEnabled()) {
|
if (tracingEnabled() && category.isDebugEnabled()) {
|
||||||
QVariantMap args = baseArgs;
|
QVariantMap args = baseArgs;
|
||||||
args["nv_payload"] = QVariant::fromValue(payload);
|
args["nv_payload"] = QVariant::fromValue(payload);
|
||||||
tracing::traceEvent(_category, _name, tracing::DurationBegin, "", args);
|
tracing::traceEvent(_category, _name, tracing::DurationBegin, "", args);
|
||||||
|
@ -48,7 +52,7 @@ Duration::Duration(const QLoggingCategory& category, const QString& name, uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
Duration::~Duration() {
|
Duration::~Duration() {
|
||||||
if (_category.isDebugEnabled()) {
|
if (tracingEnabled() && _category.isDebugEnabled()) {
|
||||||
tracing::traceEvent(_category, _name, tracing::DurationEnd);
|
tracing::traceEvent(_category, _name, tracing::DurationEnd);
|
||||||
#ifdef NSIGHT_TRACING
|
#ifdef NSIGHT_TRACING
|
||||||
nvtxRangePop();
|
nvtxRangePop();
|
||||||
|
@ -59,7 +63,7 @@ Duration::~Duration() {
|
||||||
// FIXME
|
// FIXME
|
||||||
uint64_t Duration::beginRange(const QLoggingCategory& category, const char* name, uint32_t argbColor) {
|
uint64_t Duration::beginRange(const QLoggingCategory& category, const char* name, uint32_t argbColor) {
|
||||||
#ifdef NSIGHT_TRACING
|
#ifdef NSIGHT_TRACING
|
||||||
if (category.isDebugEnabled()) {
|
if (tracingEnabled() && category.isDebugEnabled()) {
|
||||||
nvtxEventAttributes_t eventAttrib = { 0 };
|
nvtxEventAttributes_t eventAttrib = { 0 };
|
||||||
eventAttrib.version = NVTX_VERSION;
|
eventAttrib.version = NVTX_VERSION;
|
||||||
eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
||||||
|
@ -76,7 +80,7 @@ uint64_t Duration::beginRange(const QLoggingCategory& category, const char* name
|
||||||
// FIXME
|
// FIXME
|
||||||
void Duration::endRange(const QLoggingCategory& category, uint64_t rangeId) {
|
void Duration::endRange(const QLoggingCategory& category, uint64_t rangeId) {
|
||||||
#ifdef NSIGHT_TRACING
|
#ifdef NSIGHT_TRACING
|
||||||
if (category.isDebugEnabled()) {
|
if (tracingEnabled() && category.isDebugEnabled()) {
|
||||||
nvtxRangeEnd(rangeId);
|
nvtxRangeEnd(rangeId);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue