Use logging macros instead of direct calls to logging functions
LennartSchu opened this issue · 0 comments
DPsim uses spdlog for logging. In a performance-focussed environment, this may pose a problem. Spdlog and its associated functions are always executed regardless of logLevel
.
This means if, for example, in a component-model, there is a logging command such as mSLog->("The result is {}", some_expensive_function());
, then some_expensive_function()
is always executed regardless of logLevel
(even if it is off
). This may lead to performance degradations.
To avoid executing the logging-function, macros can be used. They are internally defined in spdlog.h. For example, instead of spdlog::debug
SPDLOG_LOGGER_DEBUG
can be used.
This issue has already been documented in DPsim Guidelines.
For performance reasons, these macros should be used in DPsim instead of the direct calls to the logging functions.