diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index 98001287d9a..2542a6a2b4c 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -16,6 +16,7 @@ #include #include #include +#include // getLibSupportInfoOutputFilename - This ugly hack is brought to you courtesy // of constructor/destructor ordering being unspecified by C++. Basically the @@ -178,6 +179,23 @@ void Timer::addPeakMemoryMeasurement() { (*I)->PeakMem = std::max((*I)->PeakMem, MemUsed-(*I)->PeakMemBase); } +//===----------------------------------------------------------------------===// +// NamedRegionTimer Implementation +//===----------------------------------------------------------------------===// + +static Timer &getNamedRegionTimer(const std::string &Name) { + static std::map NamedTimers; + + std::map::iterator I = NamedTimers.lower_bound(Name); + if (I != NamedTimers.end() && I->first == Name) + return I->second; + + return NamedTimers.insert(I, std::make_pair(Name, Timer(Name)))->second; +} + +NamedRegionTimer::NamedRegionTimer(const std::string &Name) + : TimeRegion(getNamedRegionTimer(Name)) {} + //===----------------------------------------------------------------------===// // TimerGroup Implementation