7 #ifndef PXR_IMAGING_HD_PERF_LOG_H
8 #define PXR_IMAGING_HD_PERF_LOG_H
17 #include "pxr/base/tf/mallocTag.h"
28 #if !defined(HD_PERF_ENABLE)
29 #define HD_PERF_ENABLE 1
44 #define HD_TRACE_FUNCTION() TRACE_FUNCTION()
46 #define HD_TRACE_SCOPE(tag) TRACE_SCOPE(tag)
50 #define HD_PERF_CACHE_HIT(name, id) \
51 HdPerfLog::GetInstance().AddCacheHit(name, id);
52 #define HD_PERF_CACHE_HIT_TAG(name, id, tag) \
53 HdPerfLog::GetInstance().AddCacheHit(name, id, tag);
57 #define HD_PERF_CACHE_MISS(name, id) \
58 HdPerfLog::GetInstance().AddCacheMiss(name, id);
59 #define HD_PERF_CACHE_MISS_TAG(name, id, tag) \
60 HdPerfLog::GetInstance().AddCacheMiss(name, id, tag);
64 #define HD_PERF_COUNTER_INCR(name) \
65 HdPerfLog::GetInstance().IncrementCounter(name);
66 #define HD_PERF_COUNTER_DECR(name) \
67 HdPerfLog::GetInstance().DecrementCounter(name);
68 #define HD_PERF_COUNTER_SET(name, value) \
69 HdPerfLog::GetInstance().SetCounter(name, value);
70 #define HD_PERF_COUNTER_ADD(name, value) \
71 HdPerfLog::GetInstance().AddCounter(name, value);
72 #define HD_PERF_COUNTER_SUBTRACT(name, value) \
73 HdPerfLog::GetInstance().SubtractCounter(name, value);
76 #define HD_PERF_ADD_RESOURCE_REGISTRY(registry) \
77 HdPerfLog::GetInstance().AddResourceRegistry(registry);
78 #define HD_PERF_REMOVE_RESOURCE_REGISTRY(registry) \
79 HdPerfLog::GetInstance().RemoveResourceRegistry(registry);
81 #else // HD_PERF_ENABLE
83 #define HD_TRACE_FUNCTION()
84 #define HD_TRACE_SCOPE(tag)
86 #define HD_PERF_CACHE_HIT(name, id)
87 #define HD_PERF_CACHE_HIT_TAG(name, id, tag)
89 #define HD_PERF_CACHE_MISS(name, id)
90 #define HD_PERF_CACHE_MISS_TAG(name, id, tag)
92 #define HD_PERF_COUNTER_INCR(name)
93 #define HD_PERF_COUNTER_DECR(name)
94 #define HD_PERF_COUNTER_SET(name, value) (void)(value)
95 #define HD_PERF_COUNTER_ADD(name, value) (void)(value)
96 #define HD_PERF_COUNTER_SUBTRACT(name, value) (void)(value)
98 #define HD_PERF_ADD_RESOURCE_REGISTRY(registry)
99 #define HD_PERF_REMOVE_RESOURCE_REGISTRY(registry)
217 _CacheEntry() : _hits(0), _misses(0) { }
219 void AddHit() {++_hits;}
220 size_t GetHits() {
return _hits;}
222 void AddMiss() {++_misses;}
223 size_t GetMisses() {
return _misses;}
225 size_t GetTotal() {
return _hits+_misses;}
226 double GetHitRatio() {
return (
double)_hits / GetTotal();}
228 void Reset() { _hits = 0; _misses = 0; }
240 _CounterMap _counterMap;
243 std::vector<HdResourceRegistry *> _resourceRegistryVector;
248 typedef std::lock_guard<std::mutex> _Lock;
255 #endif // PXR_IMAGING_HD_PERF_LOG_H
HD_API void IncrementCounter(TfToken const &name)
Increments a named counter by 1.0.
void Disable()
Disable performance logging.
HD_API void SubtractCounter(TfToken const &name, double value)
Subtracts value to a named counter.
#define PXR_NAMESPACE_OPEN_SCOPE
GLsizei const GLfloat * value
HD_API void ResetCache(TfToken const &name)
HD_API void AddCounter(TfToken const &name, double value)
Adds value to a named counter.
HD_API TfTokenVector GetCacheNames()
Returns the names of all cache performance counters.
HD_API_TEMPLATE_CLASS(TfSingleton< HdPerfLog >)
HD_API TfTokenVector GetCounterNames()
Returns a vector of all performance counter names.
HD_API void SetCounter(TfToken const &name, double value)
Sets the value of a named counter.
HD_API double GetCounter(TfToken const &name)
Returns the current value of a named counter.
HD_API void ResetCounters()
void Enable()
Enable performance logging.
std::vector< TfToken > TfTokenVector
Convenience types.
GLuint const GLchar * name
HD_API void AddCacheHit(TfToken const &name, SdfPath const &id, TfToken const &tag=TfToken())
HD_API void AddCacheMiss(TfToken const &name, SdfPath const &id, TfToken const &tag=TfToken())
HD_API void DecrementCounter(TfToken const &name)
Decrements a named counter by 1.0.
HD_API void AddResourceRegistry(HdResourceRegistry *resourceRegistry)
Add a resource registry to the tracking.
#define PXR_NAMESPACE_CLOSE_SCOPE
static HD_API HdPerfLog & GetInstance()
HD_API std::vector< HdResourceRegistry * > const & GetResourceRegistryVector()
Returns a vector of resource registry.
HD_API size_t GetCacheMisses(TfToken const &name)
Gets the number of hit misses for a cache performance counter.
HD_API size_t GetCacheHits(TfToken const &name)
Gets the number of hit hits for a cache performance counter.
HD_API void RemoveResourceRegistry(HdResourceRegistry *resourceRegistry)
Remove Resource Registry from the tracking.
HD_API double GetCacheHitRatio(TfToken const &name)