Class PerformanceTracker

Synopsis

#include <src/easylogging++.h>

class PerformanceTracker : public base::threading::ThreadSafe, public Loggable

Description

Represents performanceTracker block of code that conditionally adds performance status to log either when goes outside the scope of when checkpoint() is called.

Mentioned in

Inheritance

Ancestors: ThreadSafe, Loggable

Methods

PerformanceTracker overloadPerformanceTracker.
PerformanceTracker overloadCopy constructor.
~PerformanceTracker
checkpointA checkpoint for current performanceTracker block.
level

Source

Lines 3469-3514 in src/easylogging++.h.

class PerformanceTracker : public base::threading::ThreadSafe, public Loggable {
 public:
  PerformanceTracker(const std::string& blockName,
                     base::TimestampUnit timestampUnit = base::TimestampUnit::Millisecond,
                     const std::string& loggerId = std::string(el::base::consts::kPerformanceLoggerId),
                     bool scopedLog = true, Level level = base::consts::kPerformanceTrackerDefaultLevel);
  /// @brief Copy constructor
  PerformanceTracker(const PerformanceTracker& t) :
    m_blockName(t.m_blockName), m_timestampUnit(t.m_timestampUnit), m_loggerId(t.m_loggerId), m_scopedLog(t.m_scopedLog),
    m_level(t.m_level), m_hasChecked(t.m_hasChecked), m_lastCheckpointId(t.m_lastCheckpointId), m_enabled(t.m_enabled),
    m_startTime(t.m_startTime), m_endTime(t.m_endTime), m_lastCheckpointTime(t.m_lastCheckpointTime) {
  }
  virtual ~PerformanceTracker(void);
  /// @brief A checkpoint for current performanceTracker block.
  void checkpoint(const std::string& id = std::string(), const char* file = __FILE__,
                  base::type::LineNumber line = __LINE__,
                  const char* func = "");
  inline Level level(void) const {
    return m_level;
  }
 private:
  std::string m_blockName;
  base::TimestampUnit m_timestampUnit;
  std::string m_loggerId;
  bool m_scopedLog;
  Level m_level;
  bool m_hasChecked;
  std::string m_lastCheckpointId;
  bool m_enabled;
  struct timeval m_startTime, m_endTime, m_lastCheckpointTime;

  PerformanceTracker(void);

  friend class el::PerformanceTrackingData;
  friend class base::DefaultPerformanceTrackingCallback;

  const inline base::type::string_t getFormattedTimeTaken() const {
    return getFormattedTimeTaken(m_startTime);
  }

  const base::type::string_t getFormattedTimeTaken(struct timeval startTime) const;

  virtual inline void log(el::base::type::ostream_t& os) const {
    os << getFormattedTimeTaken();
  }
};





Add Discussion

Log in to comment