diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-06 15:02:31 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-06 15:02:31 +0000 |
commit | d5a310e4b3251410d4afd58ccea5ec7f0cb13d5f (patch) | |
tree | 2e5562674dd661cab68de93d3d18937a49a32577 /lib/Support/Timer.cpp | |
parent | aacd3c8d86d6d4aa69ddae8814b4839a4973028a (diff) |
Implement the NamedRegionTimer class
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8889 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Timer.cpp')
-rw-r--r-- | lib/Support/Timer.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index 98001287d9..2542a6a2b4 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -16,6 +16,7 @@ #include <algorithm> #include <functional> #include <fstream> +#include <map> // 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<std::string, Timer> NamedTimers; + + std::map<std::string, Timer>::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 |