ewmscp  ..
timer.cpp
Go to the documentation of this file.
1 #include "timer.h"
2 
3 namespace timer {
5  void anchor::print(std::ostream& out, const std::string& prefix) {
6  double totalTime = 0;
7  unsigned int totalCalls = 0;
8  std::unique_lock<decltype(listMutex)> lock(listMutex);
9  for (const auto item : getList()) {
10  double t = item->timeSpent / 1e9;
11  out << prefix
12  << item->getFile() << ":"
13  << item->getLine() << ": "
14  << item->getFunc() << ": "
15  << item->subfunc << ": "
16  << item->counter << " avg ";
17  if (item->counter > 0) {
18  out << t / item->counter << "s tot ";
19  } else {
20  out << "-- tot ";
21  }
22  out << t << "s max ";
23  out << item->maxTimeSpent/ 1e9 << "s \n";
24  totalTime += t;
25  totalCalls += item->counter;
26  }
27  out << prefix << "spent " << totalTime << "s in " << totalCalls << " calls\n";
28  }
29 };
timer
Definition: timer.cpp:3
timer::anchor::print
static void print(std::ostream &out, const std::string &prefix)
Definition: timer.cpp:5
timer.h
timer::anchor::getList
static std::set< anchor *, pointerCompare > & getList()
Definition: timer.h:49
timer::anchor::listMutex
static std::mutex listMutex
Definition: timer.h:48