Skip to content

Commit

Permalink
Workaround for unused Scope::m_domain
Browse files Browse the repository at this point in the history
  • Loading branch information
dkargin committed Jul 8, 2023
1 parent 10f0539 commit 0e2abea
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/profiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@ Domain::~Domain()
}
}

// Global domain for warzone.
Domain wzRootDomain{"warzone2100"};

Scope::Scope(const Domain *domain, const char *name)
:m_domain(domain)
{
if (domain && name)
timespec_get(&m_startTimeStamp, TIME_UTC);

if (m_domain && name)
{
#ifdef WZ_PROFILING_NVTX
{
Expand All @@ -85,6 +88,8 @@ Scope::Scope(const Domain *domain, const char *name)
Scope::Scope(const Domain *domain, const char *object, const char *name)
:m_domain(domain)
{
timespec_get(&m_startTimeStamp, TIME_UTC);

if (m_domain && object && name)
{
static char tmpBuffer[255];
Expand Down Expand Up @@ -117,6 +122,16 @@ Scope::~Scope()
}
}

double deltaTimeSec(timespec from, timespec to) {
return (to.tv_sec - from.tv_sec) + 0.000000001 * (to.tv_nsec - from.tv_nsec);
}

double Scope::elapsed() const {
timespec currentTime;
timespec_get(&currentTime, TIME_UTC);
return deltaTimeSec(m_startTimeStamp, currentTime);
}

void mark(const Domain *domain, const char *mark)
{
if (!domain || !mark)
Expand Down
12 changes: 11 additions & 1 deletion src/profiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,24 @@ class Scope
Scope(const Domain* domain, const char* object, const char* name);
~Scope();

/// Get a domain.
const Domain* domain() const {
return m_domain;
}
/// Get time from scope start, in seconds.
double elapsed() const;

private:
timespec m_prevTimeStamp;
timespec m_startTimeStamp;
const Domain* m_domain = nullptr;
uint64_t m_backendRangeId = 0;
};

extern Domain wzRootDomain;

void mark(const Domain *domain, const char *mark);
void mark(const Domain *domain, const char *object, const char *mark);

}

#define WZ_PROFILE_SCOPE(name) profiling::Scope mark_##name(&profiling::wzRootDomain, #name);
Expand Down

0 comments on commit 0e2abea

Please sign in to comment.