31 #ifdef NO_TIME_ELAPSED_MEASUREMENT
32 # define TIME_ELAPSED_N(n,...) time_elapsed_impl_noop<n>([&]{__VA_ARGS__;})
33 # define TIME_ELAPSED_MARKER_N(n,marker,...) time_elapsed_impl_noop<n>([&]{__VA_ARGS__;})
35 # define TIME_ELAPSED_N(n,...) time_elapsed_impl1<n>([&]{__VA_ARGS__;},__FILE__,__LINE__)
36 # define TIME_ELAPSED_MARKER_N(n,marker,...) time_elapsed_impl_core<n>([&]{__VA_ARGS__;},marker)
39 #define TIME_ELAPSED(...) TIME_ELAPSED_N(1,__VA_ARGS__)
40 #define TIME_ELAPSED_MARKER(marker,...) TIME_ELAPSED_MARKER_N(1,marker,__VA_ARGS__)
42 template<const
int count,
typename BlockBody>
43 inline void time_elapsed_impl_core(BlockBody body,
const std::string& header) {
44 auto t0 = std::chrono::high_resolution_clock::now();
45 for (
int i = 0; i < count; i++)
48 auto t1 = std::chrono::high_resolution_clock::now();
49 const float millis = (float) std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count() / 1000.0f;
50 ai_log(
"ElapsedTime: %s, cnt: %i - %0.3fmsec", header.c_str(), count, millis);
53 template<const
int count,
typename BlockBody>
54 inline void time_elapsed_impl_noop(BlockBody body) {
55 for (
int i = 0; i < count; i++)
59 template<
int count,
typename BlockBody>
60 inline void time_elapsed_impl1(BlockBody body,
const char *
const path,
const int lno) {
61 std::string basename { path + std::string(path).find_last_of(
"\\/") + 1 };
62 time_elapsed_impl_core<count>(body, basename +
" at L." + std::to_string(lno));
#define ai_log(...)
Logging macro to provide your own loggers.
Definition: Types.h:16