mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
finally, maintain a global list of timer groups, allowing us to
implement TimerGroup::printAll, which prints and resets all active timers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99876 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ecdbff8c74
commit
83fa78efb1
@ -164,12 +164,12 @@ class TimerGroup {
|
|||||||
std::string Name;
|
std::string Name;
|
||||||
Timer *FirstTimer; // First timer in the group.
|
Timer *FirstTimer; // First timer in the group.
|
||||||
std::vector<std::pair<TimeRecord, std::string> > TimersToPrint;
|
std::vector<std::pair<TimeRecord, std::string> > TimersToPrint;
|
||||||
|
|
||||||
|
TimerGroup **Prev, *Next; // Doubly linked list of TimerGroup's.
|
||||||
TimerGroup(const TimerGroup &TG); // DO NOT IMPLEMENT
|
TimerGroup(const TimerGroup &TG); // DO NOT IMPLEMENT
|
||||||
void operator=(const TimerGroup &TG); // DO NOT IMPLEMENT
|
void operator=(const TimerGroup &TG); // DO NOT IMPLEMENT
|
||||||
public:
|
public:
|
||||||
explicit TimerGroup(const std::string &name = "")
|
explicit TimerGroup(const std::string &name);
|
||||||
: Name(name), FirstTimer(0) {}
|
|
||||||
|
|
||||||
~TimerGroup();
|
~TimerGroup();
|
||||||
|
|
||||||
void setName(const std::string &name) { Name = name; }
|
void setName(const std::string &name) { Name = name; }
|
||||||
@ -177,6 +177,9 @@ public:
|
|||||||
/// print - Print any started timers in this group and zero them.
|
/// print - Print any started timers in this group and zero them.
|
||||||
void print(raw_ostream &OS);
|
void print(raw_ostream &OS);
|
||||||
|
|
||||||
|
/// printAll - This static method prints all timers and clears them all out.
|
||||||
|
static void printAll(raw_ostream &OS);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Timer;
|
friend class Timer;
|
||||||
void addTimer(Timer &T);
|
void addTimer(Timer &T);
|
||||||
|
@ -239,11 +239,33 @@ NamedRegionTimer::NamedRegionTimer(const std::string &Name,
|
|||||||
// TimerGroup Implementation
|
// TimerGroup Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
/// TimerGroupList - This is the global list of TimerGroups, maintained by the
|
||||||
|
/// TimerGroup ctor/dtor and is protected by the TimerLock lock.
|
||||||
|
static TimerGroup *TimerGroupList = 0;
|
||||||
|
|
||||||
|
TimerGroup::TimerGroup(const std::string &name)
|
||||||
|
: Name(name), FirstTimer(0) {
|
||||||
|
|
||||||
|
// Add the group to TimerGroupList.
|
||||||
|
sys::SmartScopedLock<true> L(*TimerLock);
|
||||||
|
if (TimerGroupList)
|
||||||
|
TimerGroupList->Prev = &Next;
|
||||||
|
Next = TimerGroupList;
|
||||||
|
Prev = &TimerGroupList;
|
||||||
|
TimerGroupList = this;
|
||||||
|
}
|
||||||
|
|
||||||
TimerGroup::~TimerGroup() {
|
TimerGroup::~TimerGroup() {
|
||||||
// If the timer group is destroyed before the timers it owns, accumulate and
|
// If the timer group is destroyed before the timers it owns, accumulate and
|
||||||
// print the timing data.
|
// print the timing data.
|
||||||
while (FirstTimer != 0)
|
while (FirstTimer != 0)
|
||||||
removeTimer(*FirstTimer);
|
removeTimer(*FirstTimer);
|
||||||
|
|
||||||
|
// Remove the group from the TimerGroupList.
|
||||||
|
sys::SmartScopedLock<true> L(*TimerLock);
|
||||||
|
*Prev = Next;
|
||||||
|
if (Next)
|
||||||
|
Next->Prev = Prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -352,3 +374,11 @@ void TimerGroup::print(raw_ostream &OS) {
|
|||||||
if (!TimersToPrint.empty())
|
if (!TimersToPrint.empty())
|
||||||
PrintQueuedTimers(OS);
|
PrintQueuedTimers(OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// printAll - This static method prints all timers and clears them all out.
|
||||||
|
void TimerGroup::printAll(raw_ostream &OS) {
|
||||||
|
sys::SmartScopedLock<true> L(*TimerLock);
|
||||||
|
|
||||||
|
for (TimerGroup *TG = TimerGroupList; TG; TG = TG->Next)
|
||||||
|
TG->print(OS);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user