X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FSupport%2FTimer.h;h=404cb6d6c8b69c316151df1270c656a1b693ad9e;hb=5eb301740c4ee5d978535caa917cc004733a7fca;hp=2997a8744cc05945abe162eb9bd3b28a02140c36;hpb=9f9f6d19dd67926446fb89a7b2dc0bda6353645b;p=oota-llvm.git diff --git a/include/llvm/Support/Timer.h b/include/llvm/Support/Timer.h index 2997a8744cc..404cb6d6c8b 100644 --- a/include/llvm/Support/Timer.h +++ b/include/llvm/Support/Timer.h @@ -15,7 +15,8 @@ #ifndef LLVM_SUPPORT_TIMER_H #define LLVM_SUPPORT_TIMER_H -#include "llvm/System/DataTypes.h" +#include "llvm/Support/DataTypes.h" +#include "llvm/ADT/StringRef.h" #include #include #include @@ -88,8 +89,8 @@ class Timer { 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); } + explicit Timer(StringRef N) : TG(0) { init(N); } + Timer(StringRef N, TimerGroup &tg) : TG(0) { init(N, tg); } Timer(const Timer &RHS) : TG(0) { assert(RHS.TG == 0 && "Can only copy uninitialized timers"); } @@ -101,8 +102,8 @@ public: // Create an uninitialized timer, client must use 'init'. explicit Timer() : TG(0) {} - void init(const std::string &N); - void init(const std::string &N, TimerGroup &tg); + void init(StringRef N); + void init(StringRef N, TimerGroup &tg); const std::string &getName() const { return Name; } bool isInitialized() const { return TG != 0; } @@ -149,9 +150,10 @@ public: /// is primarily used for debugging and for hunting performance problems. /// struct NamedRegionTimer : public TimeRegion { - explicit NamedRegionTimer(const std::string &Name); - explicit NamedRegionTimer(const std::string &Name, - const std::string &GroupName); + explicit NamedRegionTimer(StringRef Name, + bool Enabled = true); + explicit NamedRegionTimer(StringRef Name, StringRef GroupName, + bool Enabled = true); }; @@ -164,30 +166,27 @@ class TimerGroup { std::string Name; Timer *FirstTimer; // First timer in the group. std::vector > TimersToPrint; + + TimerGroup **Prev, *Next; // Doubly linked list of TimerGroup's. + TimerGroup(const TimerGroup &TG); // DO NOT IMPLEMENT + void operator=(const TimerGroup &TG); // DO NOT IMPLEMENT public: - explicit TimerGroup(const std::string &name) : Name(name), FirstTimer(0) {} - explicit TimerGroup() : FirstTimer(0) {} - - explicit TimerGroup(const TimerGroup &TG) : FirstTimer(0) { - operator=(TG); - } + explicit TimerGroup(StringRef name); ~TimerGroup(); - void operator=(const TimerGroup &TG) { - assert(TG.FirstTimer == 0 && FirstTimer == 0 && - "Cannot assign group with timers"); - Name = TG.Name; - } + void setName(StringRef name) { Name.assign(name.begin(), name.end()); } + /// print - Print any started timers in this group and zero them. + void print(raw_ostream &OS); - void setName(const std::string &name) { Name = name; } - - void PrintQueuedTimers(raw_ostream &OS); + /// printAll - This static method prints all timers and clears them all out. + static void printAll(raw_ostream &OS); private: friend class Timer; void addTimer(Timer &T); void removeTimer(Timer &T); + void PrintQueuedTimers(raw_ostream &OS); }; } // End llvm namespace