| | #ifndef OPENPOSE_UTILITIES_PROFILER_HPP |
| | #define OPENPOSE_UTILITIES_PROFILER_HPP |
| |
|
| | #include <chrono> |
| | #include <string> |
| | #include <openpose/core/macros.hpp> |
| | #include <openpose/utilities/enumClasses.hpp> |
| |
|
| | namespace op |
| | { |
| | |
| | |
| | |
| | |
| | |
| | OP_API std::chrono::time_point<std::chrono::high_resolution_clock> getTimerInit(); |
| |
|
| | 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); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #define OP_PROFILE_INIT(REPS) \ |
| | { \ |
| | const auto timerInit = getTimerInit(); \ |
| | for (auto rep = 0 ; rep < (REPS) ; ++rep) \ |
| | { |
| | #define OP_PROFILE_END(finalTime, factor, REPS) \ |
| | } \ |
| | (finalTime) = (factor)/(float)(REPS)*getTimeSeconds(timerInit); \ |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #define OP_CUDA_PROFILE_INIT(REPS) \ |
| | { \ |
| | cudaDeviceSynchronize(); \ |
| | const auto timerInit = getTimerInit(); \ |
| | for (auto rep = 0 ; rep < (REPS) ; ++rep) \ |
| | { |
| | |
| | |
| | #define OP_CUDA_PROFILE_END(finalTime, factor, REPS) \ |
| | } \ |
| | cudaDeviceSynchronize(); \ |
| | (finalTime) = (factor)/(float)(REPS)*getTimeSeconds(timerInit); \ |
| | cudaCheck(__LINE__, __FUNCTION__, __FILE__); \ |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | class OP_API Profiler |
| | { |
| | public: |
| | static unsigned long long DEFAULT_X; |
| |
|
| | |
| | static void setDefaultX(const unsigned long long defaultX); |
| |
|
| | static const std::string timerInit(const int line, const std::string& function, const std::string& file); |
| |
|
| | static void timerEnd(const std::string& key); |
| |
|
| | 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 printAveragedTimeMsEveryXIterations( |
| | 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); |
| | }; |
| | } |
| |
|
| | #endif |
| |
|