2 #ifndef _NNDEPLOY_BASE_TIME_PROFILER_H_
3 #define _NNDEPLOY_BASE_TIME_PROFILER_H_
19 void start(
const std::string &key);
20 void end(
const std::string &key);
23 void print(
const std::string &title =
"");
24 void printIndex(
const std::string &title, uint64_t index);
33 Record(
const std::string &key, int64_t order, uint64_t start,
int max_size)
41 cost_time_.resize(max_size);
43 Record(
const std::string &key, int64_t order, uint64_t start,
float flops,
52 cost_time_.resize(max_size);
58 std::vector<uint64_t> cost_time_;
59 uint64_t cost_time_sum_;
66 std::map<std::string, std::shared_ptr<Record>> records_;
86 const std::string &title, uint64_t warmup_times);
110 uint64_t
current()
const {
return mLastResetTime; }
135 uint64_t mCurrentTime;
141 #ifdef ENABLE_NNDEPLOY_TIME_PROFILER
142 #define NNDEPLOY_TIME_PROFILER_RESET() nndeploy::base::timeProfilerReset()
143 #define NNDEPLOY_TIME_POINT_START(key) nndeploy::base::timePointStart(key)
144 #define NNDEPLOY_TIME_POINT_END(key) nndeploy::base::timePointEnd(key)
145 #define NNDEPLOY_TIME_PROFILER_GET_COST_TIME(key) \
146 nndeploy::base::timeProfilerGetCostTime(key)
147 #define NNDEPLOY_TIME_PROFILER_GET_AVERAGE_TIME(key) \
148 nndeploy::base::timeProfilerGetAverageTime(key)
149 #define NNDEPLOY_TIME_PROFILER_PRINT(title) \
150 nndeploy::base::timeProfilerPrint(title)
151 #define NNDEPLOY_TIME_PROFILER_PRINT_INDEX(title, index) \
152 nndeploy::base::timeProfilerPrintIndex(title, index)
153 #define NNDEPLOY_TIME_PROFILER_PRINT_REMOVE_WARMUP(title, warmup_times) \
154 nndeploy::base::timeProfilerPrintRemoveWarmup(title, warmup_times)
155 #define NNDEPLOY_AUTO_TIME nndeploy::base::AutoTime ___t(__LINE__, __func__)
157 #define NNDEPLOY_TIME_PROFILER_RESET()
158 #define NNDEPLOY_TIME_POINT_START(key)
159 #define NNDEPLOY_TIME_POINT_END(key)
160 #define NNDEPLOY_TIME_PROFILER_GET_COST_TIME(key) -1.0f
161 #define NNDEPLOY_TIME_PROFILER_GET_AVERAGE_TIME(key) -1.0f
162 #define NNDEPLOY_TIME_PROFILER_PRINT(title)
163 #define NNDEPLOY_TIME_PROFILER_PRINT_INDEX(title, index)
164 #define NNDEPLOY_TIME_PROFILER_PRINT_REMOVE_WARMUP(title, warmup_times)
165 #define NNDEPLOY_AUTO_TIME
AutoTime & operator=(const AutoTime &)=delete
AutoTime & operator=(const AutoTime &&)=delete
AutoTime(const AutoTime &&)=delete
AutoTime(int line, const char *func)
AutoTime(const AutoTime &)=delete
void printIndex(const std::string &title, uint64_t index)
float getAverageTime(const std::string &key) const
void printRemoveWarmup(const std::string &title, uint64_t warmup_times)
float getCostTime(const std::string &key) const
void print(const std::string &title="")
void end(const std::string &key)
void start(const std::string &key)
Timer(const Timer &&)=delete
Timer(const Timer &)=delete
Timer & operator=(const Timer &&)=delete
Timer & operator=(const Timer &)=delete
#define NNDEPLOY_CC_API
api
void timeProfilerPrint(const std::string &title="")
float timeProfilerGetAverageTime(const std::string &key)
float timeProfilerGetCostTime(const std::string &key)
void timePointEnd(const std::string &key)
void timeProfilerPrintIndex(const std::string &title, uint64_t index)
void timeProfilerPrintRemoveWarmup(const std::string &title, uint64_t warmup_times)
void timePointStart(const std::string &key)