diff options
author | Matthias Braun <matze@braunis.de> | 2016-11-18 19:43:18 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2016-11-18 19:43:18 +0000 |
commit | 9f15a79e5d89a814480eb2e0e53ff0e13d56fc8f (patch) | |
tree | 9ac5e562dd11f972a05a4878d32dfc27588fe34c /llvm/lib/Support/Timer.cpp | |
parent | b51774ac8ca27bb4705a61754781382fadbd1f22 (diff) | |
download | llvm-9f15a79e5d89a814480eb2e0e53ff0e13d56fc8f.zip llvm-9f15a79e5d89a814480eb2e0e53ff0e13d56fc8f.tar.gz llvm-9f15a79e5d89a814480eb2e0e53ff0e13d56fc8f.tar.bz2 |
Timer: Track name and description.
The previously used "names" are rather descriptions (they use multiple
words and contain spaces), use short programming language identifier
like strings for the "names" which should be used when exporting to
machine parseable formats.
Also removed a unused TimerGroup from Hexxagon.
Differential Revision: https://reviews.llvm.org/D25583
llvm-svn: 287369
Diffstat (limited to 'llvm/lib/Support/Timer.cpp')
-rw-r--r-- | llvm/lib/Support/Timer.cpp | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp index 548f9da..cca538c 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(); |