-void TimerGroup::removeTimer() {
- if (--NumTimers == 0 && !TimersToPrint.empty()) { // Print timing report...
- // Sort the timers in descending order by amount of time taken...
- std::sort(TimersToPrint.begin(), TimersToPrint.end(),
- std::greater<Timer>());
-
- // Figure out how many spaces to indent TimerGroup name...
- unsigned Padding = (80-Name.length())/2;
- if (Padding > 80) Padding = 0; // Don't allow "negative" numbers
-
- std::ostream *OutStream = GetLibSupportInfoOutputFile();
-
- ++NumTimers;
- { // Scope to contain Total timer... don't allow total timer to drop us to
- // zero timers...
- Timer Total("TOTAL");
-
- for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i)
- Total.sum(TimersToPrint[i]);
-
- // Print out timing header...
- *OutStream << "===" << std::string(73, '-') << "===\n"
- << std::string(Padding, ' ') << Name << "\n"
- << "===" << std::string(73, '-')
- << "===\n";
-
- // If this is not an collection of ungrouped times, print the total time.
- // Ungrouped timers don't really make sense to add up. We still print the
- // TOTAL line to make the percentages make sense.
- if (this != DefaultTimerGroup) {
- *OutStream << " Total Execution Time: ";
-
- printAlignedFP(Total.getProcessTime() / 1000000.0, 4, 5, *OutStream);
- *OutStream << " seconds (";
- printAlignedFP(Total.getWallTime() / 1000000.0, 4, 5, *OutStream);
- *OutStream << " wall clock)\n";
- }
- *OutStream << "\n";
-
- if (Total.UserTime / 1000000.0)
- *OutStream << " ---User Time---";
- if (Total.SystemTime / 1000000.0)
- *OutStream << " --System Time--";
- if (Total.getProcessTime() / 1000000.0)
- *OutStream << " --User+System--";
- *OutStream << " ---Wall Time---";
- if (Total.getMemUsed() / 1000000.0)
- *OutStream << " ---Mem---";
- if (Total.getPeakMem() / 1000000.0)
- *OutStream << " -PeakMem-";
- *OutStream << " --- Name ---\n";
-
- // Loop through all of the timing data, printing it out...
- for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i)
- TimersToPrint[i].print(Total, *OutStream);
-
- Total.print(Total, *OutStream);
- *OutStream << std::endl; // Flush output
- }
- --NumTimers;
-
- TimersToPrint.clear();
-
- if (OutStream != cerr.stream() && OutStream != cout.stream())
- delete OutStream; // Close the file...