struct mrpt::system::CTimeLoggerEntry
Python API: mrpt.system.CTimeLoggerEntry
Overview
A safe way to call enter() and leave() of a mrpt::system::CTimeLogger upon construction and destruction of this auxiliary object, making sure that leave() will be called upon exceptions, etc.
Usage mode #1 (scoped):
CTimeLogger logger; // ... { // Start of scope to be monitorized CTimeLoggerEntry tle(logger,"operation-name"); // do whatever } // End of scope // **DO NOT** call tle.stop() explicitly here, it's called by its dtor
Usage mode #2 (unscoped):
CTimeLogger logger; // ... CTimeLoggerEntry tle(logger,"operation-name"); // do whatever tle.stop(); // tle dtor does nothing else, since you already called stop()
The target section is resolved once at construction and cached, so the elapsed time is recorded without a second lookup. As a consequence, the logger’s clear(true) (deep clear) must not be called while an entry is alive, since it frees the section entries (clear(false) is safe).
#include <mrpt/system/CTimeLogger.h> struct CTimeLoggerEntry { // fields CTimeLogger& m_logger; // construction CTimeLoggerEntry( const CTimeLogger& logger, const std::string_view& section_name ); // methods void stop(); };
Methods
void stop()
for correct use, see docs for CTimeLoggerEntry