[PATCH] D50874: [Support] Add a public API to allow clearing all (static) timer groups.
Graydon Hoare via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 16 21:14:08 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339980: [Support] Add a public API to allow clearing all (static) timer groups. (authored by graydon, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D50874
Files:
llvm/trunk/include/llvm/Support/Timer.h
llvm/trunk/lib/Support/Timer.cpp
Index: llvm/trunk/lib/Support/Timer.cpp
===================================================================
--- llvm/trunk/lib/Support/Timer.cpp
+++ llvm/trunk/lib/Support/Timer.cpp
@@ -343,8 +343,7 @@
}
void TimerGroup::prepareToPrintList() {
- // See if any of our timers were started, if so add them to TimersToPrint and
- // reset them.
+ // See if any of our timers were started, if so add them to TimersToPrint.
for (Timer *T = FirstTimer; T; T = T->Next) {
if (!T->hasTriggered()) continue;
bool WasRunning = T->isRunning();
@@ -368,13 +367,25 @@
PrintQueuedTimers(OS);
}
+void TimerGroup::clear() {
+ sys::SmartScopedLock<true> L(*TimerLock);
+ for (Timer *T = FirstTimer; T; T = T->Next)
+ T->clear();
+}
+
void TimerGroup::printAll(raw_ostream &OS) {
sys::SmartScopedLock<true> L(*TimerLock);
for (TimerGroup *TG = TimerGroupList; TG; TG = TG->Next)
TG->print(OS);
}
+void TimerGroup::clearAll() {
+ sys::SmartScopedLock<true> L(*TimerLock);
+ for (TimerGroup *TG = TimerGroupList; TG; TG = TG->Next)
+ TG->clear();
+}
+
void TimerGroup::printJSONValue(raw_ostream &OS, const PrintRecord &R,
const char *suffix, double Value) {
assert(yaml::needsQuotes(Name) == yaml::QuotingType::None &&
Index: llvm/trunk/include/llvm/Support/Timer.h
===================================================================
--- llvm/trunk/include/llvm/Support/Timer.h
+++ llvm/trunk/include/llvm/Support/Timer.h
@@ -206,15 +206,23 @@
Description.assign(NewDescription.begin(), NewDescription.end());
}
- /// Print any started timers in this group and zero them.
+ /// Print any started timers in this group.
void print(raw_ostream &OS);
- /// This static method prints all timers and clears them all out.
+ /// Clear all timers in this group.
+ void clear();
+
+ /// This static method prints all timers.
static void printAll(raw_ostream &OS);
+ /// Clear out all timers. This is mostly used to disable automatic
+ /// printing on shutdown, when timers have already been printed explicitly
+ /// using \c printAll or \c printJSONValues.
+ static void clearAll();
+
const char *printJSONValues(raw_ostream &OS, const char *delim);
- /// Prints all timers as JSON key/value pairs, and clears them all out.
+ /// Prints all timers as JSON key/value pairs.
static const char *printAllJSONValues(raw_ostream &OS, const char *delim);
/// Ensure global timer group lists are initialized. This function is mostly
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50874.161162.patch
Type: text/x-patch
Size: 2532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180817/79a58a81/attachment.bin>
More information about the llvm-commits
mailing list