Scroom  0.14
Scroom::Utils::Timer Class Reference

#include <timer.hh>

Collaboration diagram for Scroom::Utils::Timer:
Collaboration graph

Public Member Functions

 Timer (std::string label)
 
 ~Timer ()
 

Private Attributes

struct timespec t
 
std::string label
 
bool valid
 

Constructor & Destructor Documentation

◆ Timer()

Scroom::Utils::Timer::Timer ( std::string  label)
inline
28  : label(label)
29  {
30  valid = (0 == clock_gettime(CLOCK_MONOTONIC, &t));
31  }

◆ ~Timer()

Scroom::Utils::Timer::~Timer ( )
inline
34  {
35  struct timespec t2;
36  bool v2 = (0 == clock_gettime(CLOCK_MONOTONIC, &t2));
37  if(valid && v2)
38  {
39  double elapsed = (t2.tv_nsec - t.tv_nsec) * 1e-9;
40  elapsed += t2.tv_sec - t.tv_sec;
41  spdlog::trace("{}: {:.9f}", label, elapsed);
42  }
43  else
44  {
45  spdlog::error("{}: Clock invalid", label);
46  }
47  }

Member Data Documentation

◆ label

std::string Scroom::Utils::Timer::label
private

Referenced by ~Timer().

◆ t

struct timespec Scroom::Utils::Timer::t
private

Referenced by Timer(), and ~Timer().

◆ valid

bool Scroom::Utils::Timer::valid
private

Referenced by Timer(), and ~Timer().


The documentation for this class was generated from the following file:
Scroom::Utils::Timer::label
std::string label
Definition: timer.hh:23
Scroom::Utils::Timer::t
struct timespec t
Definition: timer.hh:22
Scroom::Utils::Timer::valid
bool valid
Definition: timer.hh:24