17 #include <unordered_map>
48 const std::string sectionName,
49 const std::string filePath,
50 const size_t lineNumber)
51 : m_sectionName(sectionName), m_filePath(filePath), m_lineNumber(lineNumber),
52 m_hash(((std::
hash<std::string>()(filePath) << 1) ^ (std::
hash<size_t>()(lineNumber) << 1)) ^ std::
hash<std::string>()(sectionName))
60 return m_hash == rhs.m_hash &&
61 m_sectionName == rhs.m_sectionName &&
62 m_filePath == rhs.m_filePath &&
63 m_lineNumber == rhs.m_lineNumber;
72 const std::string m_sectionName;
73 const std::string m_filePath;
74 const size_t m_lineNumber;
109 : m_top(top), m_parent(parent), m_hash(m_top->
hash() ^ (m_parent ? m_parent->
hash() : 0))
116 {
return (m_hash == rhs.m_hash && m_top == rhs.m_top && m_parent == rhs.m_parent); }
132 #ifndef AL_GENERATING_DOCS
134 template<>
struct hash<AL::usdmaya::ProfilerSectionTag> {
139 template<>
struct hash<AL::usdmaya::ProfilerSectionPath> {
195 assert(m_stackPos == 0);
208 typedef std::unordered_map<ProfilerSectionPath, timespec> ProfilerSectionPathLUT;
209 typedef ProfilerSectionPathLUT::const_iterator iter_t;
210 static inline bool compareTimeStamps(
const iter_t,
const iter_t);
211 static void print(std::ostream& os, iter_t,
const ProfilerSectionPathLUT&, uint32_t,
double);
213 struct ProfilerSectionStackNode
217 ProfilerSectionPathLUT::iterator m_path;
220 static inline timespec timeDiff(
const timespec startTime,
const timespec endTime)
223 if (endTime.tv_nsec < startTime.tv_nsec)
225 ts.tv_sec = endTime.tv_sec - 1 - startTime.tv_sec;
226 ts.tv_nsec = 1000000000 + endTime.tv_nsec - startTime.tv_nsec;
230 ts.tv_sec = endTime.tv_sec - startTime.tv_sec;
231 ts.tv_nsec = endTime.tv_nsec - startTime.tv_nsec;
235 static inline timespec timeAdd(timespec t1, timespec t2)
238 int32_t sec = t2.tv_sec + t1.tv_sec;
239 int32_t nsec = t2.tv_nsec + t1.tv_nsec;
240 if (nsec >= 1000000000)
251 static uint32_t m_stackPos;
252 static ProfilerSectionPathLUT m_map;
262 #define AL_BEGIN_PROFILE_SECTION(TimedSection) \
264 static const AL::usdmaya::ProfilerSectionTag __entry(#TimedSection, __FILE__, __LINE__); \
265 AL::usdmaya::Profiler::pushTime(&__entry); \
270 #define AL_END_PROFILE_SECTION() \
271 { AL::usdmaya::Profiler::popTime(); }
size_t hash() const
return the hash of this class
Definition: CodeTimings.h:68
static void pushTime(const ProfilerSectionTag *entry)
do not call directly. Use the AL_BEGIN_PROFILE_SECTION macro
static void popTime()
do not call directly. Use the AL_END_PROFILE_SECTION macro
size_t hash() const
return the hash of this class
Definition: CodeTimings.h:120
This class provides a static hash that should be unique for a line within a specific function...
Definition: CodeTimings.h:38
ProfilerSectionTag(const std::string sectionName, const std::string filePath, const size_t lineNumber)
ctor
Definition: CodeTimings.h:47
static void printReport(std::ostream &os)
call to output the report
static void clearAll()
call to clear internal timers
Definition: CodeTimings.h:193
ProfilerSectionPath(const AL::usdmaya::ProfilerSectionTag *const top, const ProfilerSectionPath *const parent=0)
ctor
Definition: CodeTimings.h:108
bool operator==(const ProfilerSectionPath &rhs) const
equality operator
Definition: CodeTimings.h:115
const uint32_t MAX_TIMESTAMP_STACK_SIZE
Definition: CodeTimings.h:32
bool operator==(const ProfilerSectionTag &rhs) const
equality operator
Definition: CodeTimings.h:58
This class represents a path made up of AL::usdmaya::ProfilerSectionTag's. It is used so that we can ...
Definition: CodeTimings.h:100
This class implements a very simple incode profiler. This profiler is NOT thread safe. It is mainly used to get some basic stats on the where the bottlenecks are during a file import/export operation. A simple example of usage:
Definition: CodeTimings.h:184