g2o
Loading...
Searching...
No Matches
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 72 of file tictoc.cpp.

Constructor & Destructor Documentation

◆ TicTocInitializer()

g2o::TicTocInitializer::TicTocInitializer ( )
inline

Definition at line 75 of file tictoc.cpp.

75{ enabled = getenv("G2O_ENABLE_TICTOC") != NULL; }

References enabled.

◆ ~TicTocInitializer()

g2o::TicTocInitializer::~TicTocInitializer ( )
inline

Definition at line 76 of file tictoc.cpp.

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

References enabled, and tictocElements.

Member Data Documentation

◆ enabled

bool g2o::TicTocInitializer::enabled

Definition at line 74 of file tictoc.cpp.

Referenced by g2o::tictoc(), TicTocInitializer(), and ~TicTocInitializer().

◆ tictocElements

TicTocMap g2o::TicTocInitializer::tictocElements

Definition at line 73 of file tictoc.cpp.

Referenced by g2o::tictoc(), and ~TicTocInitializer().


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