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 | 8bfda656d972be157387e0eab56cff97fbd63728 (patch) | |
| tree | c81114ff460f244c05bf99e25a79fadda7f9ddda /llvm/lib/Support | |
| parent | 33295466ffdba09036dd6b2c40b5f32cad06cafd (diff) | |
| download | bcm5719-llvm-8bfda656d972be157387e0eab56cff97fbd63728.tar.gz bcm5719-llvm-8bfda656d972be157387e0eab56cff97fbd63728.zip | |
Implement the NamedRegionTimer class
llvm-svn: 8889
Diffstat (limited to 'llvm/lib/Support')
| -rw-r--r-- | llvm/lib/Support/Timer.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp index 98001287d9a..2542a6a2b4c 100644 --- a/llvm/lib/Support/Timer.cpp +++ b/llvm/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 |

