mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01: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
|
||||
#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) {
|
||||
if (_category.isDebugEnabled()) {
|
||||
if (tracingEnabled() && category.isDebugEnabled()) {
|
||||
QVariantMap args = baseArgs;
|
||||
args["nv_payload"] = QVariant::fromValue(payload);
|
||||
tracing::traceEvent(_category, _name, tracing::DurationBegin, "", args);
|
||||
|
@ -48,7 +52,7 @@ Duration::Duration(const QLoggingCategory& category, const QString& name, uint32
|
|||
}
|
||||
|
||||
Duration::~Duration() {
|
||||
if (_category.isDebugEnabled()) {
|
||||
if (tracingEnabled() && _category.isDebugEnabled()) {
|
||||
tracing::traceEvent(_category, _name, tracing::DurationEnd);
|
||||
#ifdef NSIGHT_TRACING
|
||||
nvtxRangePop();
|
||||
|
@ -59,7 +63,7 @@ Duration::~Duration() {
|
|||
// FIXME
|
||||
uint64_t Duration::beginRange(const QLoggingCategory& category, const char* name, uint32_t argbColor) {
|
||||
#ifdef NSIGHT_TRACING
|
||||
if (category.isDebugEnabled()) {
|
||||
if (tracingEnabled() && category.isDebugEnabled()) {
|
||||
nvtxEventAttributes_t eventAttrib = { 0 };
|
||||
eventAttrib.version = NVTX_VERSION;
|
||||
eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
||||
|
@ -76,7 +80,7 @@ uint64_t Duration::beginRange(const QLoggingCategory& category, const char* name
|
|||
// FIXME
|
||||
void Duration::endRange(const QLoggingCategory& category, uint64_t rangeId) {
|
||||
#ifdef NSIGHT_TRACING
|
||||
if (category.isDebugEnabled()) {
|
||||
if (tracingEnabled() && category.isDebugEnabled()) {
|
||||
nvtxRangeEnd(rangeId);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue