Kagome
Polkadot Runtime Engine in C++17
profiling_logger.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_LOG_PROFILING_LOGGER_HPP
7 #define KAGOME_CORE_LOG_PROFILING_LOGGER_HPP
8 
9 #include "log/logger.hpp"
10 
11 namespace kagome::log {
12  extern Logger profiling_logger;
13 }
14 
15 #ifdef KAGOME_PROFILING
16 
18 
19 #define KAGOME_PROFILE_START(scope) \
20  auto _profiling_start_##scope = ::kagome::clock::SteadyClockImpl{}.now();
21 
22 #define KAGOME_PROFILE_END(scope) \
23  auto _profiling_end_##scope = ::kagome::clock::SteadyClockImpl{}.now(); \
24  SL_DEBUG(::kagome::log::profiling_logger, \
25  "{} took {} ms", \
26  #scope, \
27  ::std::chrono::duration_cast<::std::chrono::milliseconds>( \
28  _profiling_end_##scope - _profiling_start_##scope) \
29  .count());
30 
31 #else
32 
33 #define KAGOME_PROFILE_START(scope)
34 #define KAGOME_PROFILE_END(scope)
35 
36 #endif
37 
38 #endif // KAGOME_CORE_LOG_PROFILING_LOGGER_HPP
Logger profiling_logger
std::shared_ptr< soralog::Logger > Logger
Definition: logger.hpp:23