g2o
Public Member Functions | Public Attributes | List of all members
g2o::TicTocInitializer Struct Reference

helper for printing the struct at the end of the lifetime of the program More...

Public Member Functions

 TicTocInitializer ()
 
 ~TicTocInitializer ()
 

Public Attributes

TicTocMap tictocElements
 
bool enabled
 

Detailed Description

helper for printing the struct at the end of the lifetime of the program

Definition at line 69 of file tictoc.cpp.

Constructor & Destructor Documentation

g2o::TicTocInitializer::TicTocInitializer ( )
inline

Definition at line 73 of file tictoc.cpp.

74  {
75  enabled = getenv("G2O_ENABLE_TICTOC") != NULL;
76  }
g2o::TicTocInitializer::~TicTocInitializer ( )
inline

Definition at line 77 of file tictoc.cpp.

78  {
79  if (!enabled) {
80  return;
81  }
82 
83  if (tictocElements.size() > 0) {
84  int longestName = 0;
85  // sort the elements according to the total time and print a table
86  std::vector<TicTocElement> sortedElements;
87  sortedElements.reserve(tictocElements.size());
88  for (TicTocMap::const_iterator it = tictocElements.begin(); it != tictocElements.end(); ++it) {
89  if (it->second.numCalls == 0)
90  continue;
91  longestName = std::max(longestName, (int)it->first.size());
92  sortedElements.push_back(it->second);
93  }
94  std::sort(sortedElements.begin(), sortedElements.end());
95 
96  longestName += 4;
97 
98  // now print the table to stdout
99  printf("------------------------------------------\n");
100  printf("| TICTOC STATISTICS |\n");
101  printf("------------------------------------------\n");
102  for(std::vector<TicTocElement>::const_iterator it = sortedElements.begin(); it != sortedElements.end(); ++it) {
103  double avgTime = it->totalTime / it->numCalls;
104  printf("%s", it->algorithmPart.c_str());
105  for (int i = it->algorithmPart.size(); i < longestName; ++i)
106  putchar(' ');
107  printf("numCalls= %d\t total= %.4f\t avg= %.4f\t min= %.4f\t max= %.4f\t ema= %.4f\n",
108  it->numCalls, it->totalTime, avgTime, it->minTime, it->maxTime, it->exponentialMovingAverage);
109  }
110  printf("------------------------------------------\n");
111  }
112  }
TicTocMap tictocElements
Definition: tictoc.cpp:71

Member Data Documentation

bool g2o::TicTocInitializer::enabled

Definition at line 72 of file tictoc.cpp.

Referenced by g2o::tictoc().

TicTocMap g2o::TicTocInitializer::tictocElements

Definition at line 71 of file tictoc.cpp.

Referenced by g2o::tictoc().


The documentation for this struct was generated from the following file: