diff options
author | Chris Lattner <sabre@nondot.org> | 2010-03-29 21:24:52 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-03-29 21:24:52 +0000 |
commit | 0ea86bc411748f10b913f42ef3a71b46ace7ceb2 (patch) | |
tree | 91896ffe2c86ab99e2a8e29aa2db496380e4ab12 /lib/Support/Timer.cpp | |
parent | 34247a0f356edf45ae3ad9ce04e1f90a77c6dba7 (diff) | |
download | external_llvm-0ea86bc411748f10b913f42ef3a71b46ace7ceb2.zip external_llvm-0ea86bc411748f10b913f42ef3a71b46ace7ceb2.tar.gz external_llvm-0ea86bc411748f10b913f42ef3a71b46ace7ceb2.tar.bz2 |
various timer fixes: move operator= out of line,
eliminate the per-timer lock (timers should be
externally locked if needed), the info-output-stream
can never be dbgs(), so drop the check. Make some
stuff private.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99839 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Timer.cpp')
-rw-r--r-- | lib/Support/Timer.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index 4dbb34c..16ab55f 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -147,7 +147,6 @@ static TimeRecord getTimeRecord(bool Start) { static ManagedStatic<std::vector<Timer*> > ActiveTimers; void Timer::startTimer() { - sys::SmartScopedLock<true> L(*TimerLock); Started = true; ActiveTimers->push_back(this); TimeRecord TR = getTimeRecord(true); @@ -159,7 +158,6 @@ void Timer::startTimer() { } void Timer::stopTimer() { - sys::SmartScopedLock<true> L(*TimerLock); TimeRecord TR = getTimeRecord(false); Elapsed += TR.Elapsed; UserTime += TR.UserTime; @@ -184,14 +182,26 @@ void Timer::sum(const Timer &T) { PeakMem += T.PeakMem; } +const Timer &Timer::operator=(const Timer &T) { + Elapsed = T.Elapsed; + UserTime = T.UserTime; + SystemTime = T.SystemTime; + MemUsed = T.MemUsed; + PeakMem = T.PeakMem; + PeakMemBase = T.PeakMemBase; + Name = T.Name; + Started = T.Started; + assert(TG == T.TG && "Can only assign timers in the same TimerGroup!"); + return *this; +} + + /// addPeakMemoryMeasurement - This method should be called whenever memory /// usage needs to be checked. It adds a peak memory measurement to the /// currently active timers, which will be printed when the timer group prints /// void Timer::addPeakMemoryMeasurement() { - sys::SmartScopedLock<true> L(*TimerLock); size_t MemUsed = getMemUsage(); - for (std::vector<Timer*>::iterator I = ActiveTimers->begin(), E = ActiveTimers->end(); I != E; ++I) (*I)->PeakMem = std::max((*I)->PeakMem, MemUsed-(*I)->PeakMemBase); @@ -208,7 +218,6 @@ static void printVal(double Val, double Total, raw_ostream &OS) { } void Timer::print(const Timer &Total, raw_ostream &OS) { - sys::SmartScopedLock<true> L(*TimerLock); if (Total.UserTime) printVal(UserTime, Total.UserTime, OS); if (Total.SystemTime) @@ -219,13 +228,13 @@ void Timer::print(const Timer &Total, raw_ostream &OS) { OS << " "; - if (Total.MemUsed) { + if (Total.MemUsed) OS << format("%9lld", (long long)MemUsed) << " "; - } + if (Total.PeakMem) { - if (PeakMem) { + if (PeakMem) OS << format("%9lld", (long long)PeakMem) << " "; - } else + else OS << " "; } OS << Name << "\n"; @@ -286,15 +295,13 @@ NamedRegionTimer::NamedRegionTimer(const std::string &Name, //===----------------------------------------------------------------------===// // GetLibSupportInfoOutputFile - Return a file stream to print our output on. -raw_ostream * -llvm::GetLibSupportInfoOutputFile() { +raw_ostream *llvm::GetLibSupportInfoOutputFile() { std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename(); if (LibSupportInfoOutputFilename.empty()) return &errs(); if (LibSupportInfoOutputFilename == "-") return &outs(); - std::string Error; raw_ostream *Result = new raw_fd_ostream(LibSupportInfoOutputFilename.c_str(), Error, raw_fd_ostream::F_Append); @@ -373,7 +380,7 @@ void TimerGroup::removeTimer() { TimersToPrint.clear(); - if (OutStream != &errs() && OutStream != &outs() && OutStream != &dbgs()) + if (OutStream != &errs() && OutStream != &outs()) delete OutStream; // Close the file. } |