//
// The LLVM Compiler Infrastructure
//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
}
namespace {
- cl::opt<bool>
+ static cl::opt<bool>
TrackSpace("track-memory", cl::desc("Enable -time-passes memory "
"tracking (this may be slow)"),
cl::Hidden);
- cl::opt<std::string, true>
+ static cl::opt<std::string, true>
InfoOutputFilename("info-output-file", cl::value_desc("filename"),
cl::desc("File to append -stats and -timer output to"),
cl::Hidden, cl::location(getLibSupportInfoOutputFilename()));
void Timer::startTimer() {
Started = true;
+ ActiveTimers->push_back(this);
TimeRecord TR = getTimeRecord(true);
Elapsed -= TR.Elapsed;
UserTime -= TR.UserTime;
SystemTime -= TR.SystemTime;
MemUsed -= TR.MemUsed;
PeakMemBase = TR.MemUsed;
- ActiveTimers->push_back(this);
}
void Timer::stopTimer() {
// NamedRegionTimer Implementation
//===----------------------------------------------------------------------===//
-static ManagedStatic<std::map<std::string, Timer> > NamedTimers;
+namespace {
+
+typedef std::map<std::string, Timer> Name2Timer;
+typedef std::map<std::string, std::pair<TimerGroup, Name2Timer> > Name2Pair;
+
+}
+
+static ManagedStatic<Name2Timer> NamedTimers;
+
+static ManagedStatic<Name2Pair> NamedGroupedTimers;
static Timer &getNamedRegionTimer(const std::string &Name) {
- std::map<std::string, Timer>::iterator I = NamedTimers->lower_bound(Name);
- if (I != NamedTimers->end() && I->first == Name)
+ Name2Timer::iterator I = NamedTimers->find(Name);
+ if (I != NamedTimers->end())
return I->second;
return NamedTimers->insert(I, std::make_pair(Name, Timer(Name)))->second;
}
+static Timer &getNamedRegionTimer(const std::string &Name,
+ const std::string &GroupName) {
+
+ Name2Pair::iterator I = NamedGroupedTimers->find(GroupName);
+ if (I == NamedGroupedTimers->end()) {
+ TimerGroup TG(GroupName);
+ std::pair<TimerGroup, Name2Timer> Pair(TG, Name2Timer());
+ I = NamedGroupedTimers->insert(I, std::make_pair(GroupName, Pair));
+ }
+
+ Name2Timer::iterator J = I->second.second.find(Name);
+ if (J == I->second.second.end())
+ J = I->second.second.insert(J,
+ std::make_pair(Name,
+ Timer(Name,
+ I->second.first)));
+
+ return J->second;
+}
+
NamedRegionTimer::NamedRegionTimer(const std::string &Name)
: TimeRegion(getNamedRegionTimer(Name)) {}
+NamedRegionTimer::NamedRegionTimer(const std::string &Name,
+ const std::string &GroupName)
+ : TimeRegion(getNamedRegionTimer(Name, GroupName)) {}
//===----------------------------------------------------------------------===//
// TimerGroup Implementation