aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-30 04:40:01 +0000
committerChris Lattner <sabre@nondot.org>2010-03-30 04:40:01 +0000
commitb9312690a2a79de490ab9c439b9b5d7c9319bff8 (patch)
tree786bc99022444c296f0d471272a0dd2fae05d6ef /include
parenta782e75d487006cafffdc256b3c623307fee4dcf (diff)
downloadexternal_llvm-b9312690a2a79de490ab9c439b9b5d7c9319bff8.zip
external_llvm-b9312690a2a79de490ab9c439b9b5d7c9319bff8.tar.gz
external_llvm-b9312690a2a79de490ab9c439b9b5d7c9319bff8.tar.bz2
change TimerGroup to keep a linked list of active timers
instead of just a count of them, and refactor the guts of report printing out of removeTimer into its own method. Refactor addTimerToPrint away. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99872 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Support/Timer.h34
1 files changed, 23 insertions, 11 deletions
diff --git a/include/llvm/Support/Timer.h b/include/llvm/Support/Timer.h
index 59bab1d..aba3150 100644
--- a/include/llvm/Support/Timer.h
+++ b/include/llvm/Support/Timer.h
@@ -85,6 +85,8 @@ class Timer {
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.
+
+ Timer **Prev, *Next; // Doubly linked list of timers in the group.
public:
explicit Timer(const std::string &N) : TG(0) { init(N); }
Timer(const std::string &N, TimerGroup &tg) : TG(0) { init(N, tg); }
@@ -133,12 +135,10 @@ public:
T->startTimer();
}
explicit TimeRegion(Timer *t) : T(t) {
- if (T)
- T->startTimer();
+ if (T) T->startTimer();
}
~TimeRegion() {
- if (T)
- T->stopTimer();
+ if (T) T->stopTimer();
}
};
@@ -162,24 +162,36 @@ struct NamedRegionTimer : public TimeRegion {
///
class TimerGroup {
std::string Name;
- unsigned NumTimers;
+ Timer *FirstTimer; // First timer in the group.
std::vector<std::pair<TimeRecord, std::string> > TimersToPrint;
public:
- explicit TimerGroup(const std::string &name) : Name(name), NumTimers(0) {}
- explicit TimerGroup() : NumTimers(0) {}
+ explicit TimerGroup(const std::string &name) : Name(name), FirstTimer(0) {}
+ explicit TimerGroup() : FirstTimer(0) {}
+
+ explicit TimerGroup(const TimerGroup &TG) : FirstTimer(0) {
+ operator=(TG);
+ }
+
+ void operator=(const TimerGroup &TG) {
+ assert(TG.FirstTimer == 0 && FirstTimer == 0 &&
+ "Cannot assign group with timers");
+ Name = TG.Name;
+ }
+
void setName(const std::string &name) { Name = name; }
~TimerGroup() {
- assert(NumTimers == 0 &&
+ assert(FirstTimer == 0 &&
"TimerGroup destroyed before all contained timers!");
}
+ void PrintQueuedTimers(raw_ostream &OS);
+
private:
friend class Timer;
- void addTimer();
- void removeTimer();
- void addTimerToPrint(const TimeRecord &T, const std::string &Name);
+ void addTimer(Timer &T);
+ void removeTimer(Timer &T);
};
} // End llvm namespace