summaryrefslogtreecommitdiff
path: root/include/llvm/Support/Timer.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-29 21:24:52 +0000
committerChris Lattner <sabre@nondot.org>2010-03-29 21:24:52 +0000
commit0ea86bc411748f10b913f42ef3a71b46ace7ceb2 (patch)
tree91896ffe2c86ab99e2a8e29aa2db496380e4ab12 /include/llvm/Support/Timer.h
parent34247a0f356edf45ae3ad9ce04e1f90a77c6dba7 (diff)
downloadllvm-0ea86bc411748f10b913f42ef3a71b46ace7ceb2.tar.gz
llvm-0ea86bc411748f10b913f42ef3a71b46ace7ceb2.tar.bz2
llvm-0ea86bc411748f10b913f42ef3a71b46ace7ceb2.tar.xz
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 'include/llvm/Support/Timer.h')
-rw-r--r--include/llvm/Support/Timer.h41
1 files changed, 7 insertions, 34 deletions
diff --git a/include/llvm/Support/Timer.h b/include/llvm/Support/Timer.h
index 8a0f55d9b9..f05ede60cb 100644
--- a/include/llvm/Support/Timer.h
+++ b/include/llvm/Support/Timer.h
@@ -40,54 +40,27 @@ class Timer {
double SystemTime; // System time elapsed
ssize_t MemUsed; // Memory allocated (in bytes)
size_t PeakMem; // Peak memory used
- size_t PeakMemBase; // Temporary for peak calculation...
- std::string Name; // The name of this time variable
+ size_t PeakMemBase; // Temporary for peak memory calculation.
+ std::string Name; // The name of this time variable.
bool Started; // Has this time variable ever been started?
TimerGroup *TG; // The TimerGroup this Timer is in.
- mutable sys::SmartMutex<true> Lock; // Mutex for the contents of this Timer.
public:
explicit Timer(const std::string &N);
Timer(const std::string &N, TimerGroup &tg);
Timer(const Timer &T);
~Timer();
+private:
double getProcessTime() const { return UserTime+SystemTime; }
double getWallTime() const { return Elapsed; }
ssize_t getMemUsed() const { return MemUsed; }
size_t getPeakMem() const { return PeakMem; }
+public:
std::string getName() const { return Name; }
- const Timer &operator=(const Timer &T) {
- if (&T < this) {
- T.Lock.acquire();
- Lock.acquire();
- } else {
- Lock.acquire();
- T.Lock.acquire();
- }
-
- 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!");
-
- if (&T < this) {
- T.Lock.release();
- Lock.release();
- } else {
- Lock.release();
- T.Lock.release();
- }
-
- return *this;
- }
-
- // operator< - Allow sorting...
+ const Timer &operator=(const Timer &T);
+
+ // operator< - Allow sorting.
bool operator<(const Timer &T) const {
// Sort by Wall Time elapsed, as it is the only thing really accurate
return Elapsed < T.Elapsed;