1 #ifndef OPENPOSE_UTILITIES_PROFILER_HPP
2 #define OPENPOSE_UTILITIES_PROFILER_HPP
18 OP_API double getTimeSeconds(
const std::chrono::time_point<std::chrono::high_resolution_clock>& timerInit);
21 const std::chrono::time_point<std::chrono::high_resolution_clock>& timerInit,
const std::string& firstMessage,
22 const std::string& secondMessage,
const Priority priority);
31 #define OP_PROFILE_INIT(REPS) \
33 const auto timerInit = getTimerInit(); \
34 for (auto rep = 0 ; rep < (REPS) ; ++rep) \
36 #define OP_PROFILE_END(finalTime, factor, REPS) \
38 (finalTime) = (factor)/(float)(REPS)*getTimeSeconds(timerInit); \
51 #define OP_CUDA_PROFILE_INIT(REPS) \
53 cudaDeviceSynchronize(); \
54 const auto timerInit = getTimerInit(); \
55 for (auto rep = 0 ; rep < (REPS) ; ++rep) \
59 #define OP_CUDA_PROFILE_END(finalTime, factor, REPS) \
61 cudaDeviceSynchronize(); \
62 (finalTime) = (factor)/(float)(REPS)*getTimeSeconds(timerInit); \
63 cudaCheck(__LINE__, __FUNCTION__, __FILE__); \
84 static const std::string
timerInit(
const int line,
const std::string&
function,
const std::string& file);
89 const std::string& key,
const int line,
const std::string&
function,
const std::string& file,
90 const unsigned long long x = DEFAULT_X);
93 const std::string& key,
const int line,
const std::string&
function,
const std::string& file,
94 const unsigned long long x = DEFAULT_X);
96 static void profileGpuMemory(
const int line,
const std::string&
function,
const std::string& file);
static void printAveragedTimeMsEveryXIterations(const std::string &key, const int line, const std::string &function, const std::string &file, const unsigned long long x=DEFAULT_X)
static unsigned long long DEFAULT_X
static void setDefaultX(const unsigned long long defaultX)
static void printAveragedTimeMsOnIterationX(const std::string &key, const int line, const std::string &function, const std::string &file, const unsigned long long x=DEFAULT_X)
static void profileGpuMemory(const int line, const std::string &function, const std::string &file)
static const std::string timerInit(const int line, const std::string &function, const std::string &file)
static void timerEnd(const std::string &key)
OP_API double getTimeSeconds(const std::chrono::time_point< std::chrono::high_resolution_clock > &timerInit)
OP_API void printTime(const std::chrono::time_point< std::chrono::high_resolution_clock > &timerInit, const std::string &firstMessage, const std::string &secondMessage, const Priority priority)
OP_API std::chrono::time_point< std::chrono::high_resolution_clock > getTimerInit()