summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/Timer.cpp41
1 files changed, 23 insertions, 18 deletions
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp
index 548f9da42ee..cca538c3d25 100644
--- a/llvm/lib/Support/Timer.cpp
+++ b/llvm/lib/Support/Timer.cpp
@@ -81,7 +81,7 @@ static TimerGroup *getDefaultTimerGroup() {
sys::SmartScopedLock<true> Lock(*TimerLock);
tmp = DefaultTimerGroup;
if (!tmp) {
- tmp = new TimerGroup("Miscellaneous Ungrouped Timers");
+ tmp = new TimerGroup("misc", "Miscellaneous Ungrouped Timers");
sys::MemoryFence();
DefaultTimerGroup = tmp;
}
@@ -93,13 +93,14 @@ static TimerGroup *getDefaultTimerGroup() {
// Timer Implementation
//===----------------------------------------------------------------------===//
-void Timer::init(StringRef N) {
- init(N, *getDefaultTimerGroup());
+void Timer::init(StringRef Name, StringRef Description) {
+ init(Name, Description, *getDefaultTimerGroup());
}
-void Timer::init(StringRef N, TimerGroup &tg) {
+void Timer::init(StringRef Name, StringRef Description, TimerGroup &tg) {
assert(!TG && "Timer already initialized");
- Name.assign(N.begin(), N.end());
+ this->Name.assign(Name.begin(), Name.end());
+ this->Description.assign(Description.begin(), Description.end());
Running = Triggered = false;
TG = &tg;
TG->addTimer(*this);
@@ -193,17 +194,18 @@ public:
delete I->second.first;
}
- Timer &get(StringRef Name, StringRef GroupName) {
+ Timer &get(StringRef Name, StringRef Description, StringRef GroupName,
+ StringRef GroupDescription) {
sys::SmartScopedLock<true> L(*TimerLock);
std::pair<TimerGroup*, Name2TimerMap> &GroupEntry = Map[GroupName];
if (!GroupEntry.first)
- GroupEntry.first = new TimerGroup(GroupName);
+ GroupEntry.first = new TimerGroup(GroupName, GroupDescription);
Timer &T = GroupEntry.second[Name];
if (!T.isInitialized())
- T.init(Name, *GroupEntry.first);
+ T.init(Name, Description, *GroupEntry.first);
return T;
}
};
@@ -212,9 +214,12 @@ public:
static ManagedStatic<Name2PairMap> NamedGroupedTimers;
-NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef GroupName,
- bool Enabled)
- : TimeRegion(!Enabled ? nullptr : &NamedGroupedTimers->get(Name, GroupName)){}
+NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef Description,
+ StringRef GroupName,
+ StringRef GroupDescription, bool Enabled)
+ : TimeRegion(!Enabled ? nullptr
+ : &NamedGroupedTimers->get(Name, Description, GroupName,
+ GroupDescription)) {}
//===----------------------------------------------------------------------===//
// TimerGroup Implementation
@@ -224,9 +229,9 @@ NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef GroupName,
/// ctor/dtor and is protected by the TimerLock lock.
static TimerGroup *TimerGroupList = nullptr;
-TimerGroup::TimerGroup(StringRef name)
- : Name(name.begin(), name.end()) {
-
+TimerGroup::TimerGroup(StringRef Name, StringRef Description)
+ : Name(Name.begin(), Name.end()),
+ Description(Description.begin(), Description.end()) {
// Add the group to TimerGroupList.
sys::SmartScopedLock<true> L(*TimerLock);
if (TimerGroupList)
@@ -255,7 +260,7 @@ void TimerGroup::removeTimer(Timer &T) {
// If the timer was started, move its data to TimersToPrint.
if (T.hasTriggered())
- TimersToPrint.emplace_back(T.Time, T.Name);
+ TimersToPrint.emplace_back(T.Time, T.Description);
T.TG = nullptr;
@@ -295,9 +300,9 @@ void TimerGroup::PrintQueuedTimers(raw_ostream &OS) {
// Print out timing header.
OS << "===" << std::string(73, '-') << "===\n";
// Figure out how many spaces to indent TimerGroup name.
- unsigned Padding = (80-Name.length())/2;
+ unsigned Padding = (80-Description.length())/2;
if (Padding > 80) Padding = 0; // Don't allow "negative" numbers
- OS.indent(Padding) << Name << '\n';
+ OS.indent(Padding) << Description << '\n';
OS << "===" << std::string(73, '-') << "===\n";
// If this is not an collection of ungrouped times, print the total time.
@@ -340,7 +345,7 @@ void TimerGroup::print(raw_ostream &OS) {
// reset them.
for (Timer *T = FirstTimer; T; T = T->Next) {
if (!T->hasTriggered()) continue;
- TimersToPrint.emplace_back(T->Time, T->Name);
+ TimersToPrint.emplace_back(T->Time, T->Description);
// Clear out the time.
T->clear();
OpenPOWER on IntegriCloud