[llvm] r324788 - Make LLVM timer reprintable: that is, make more than one print action on the same timer feasible
George Karpenkov via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 9 16:38:21 PST 2018
Author: george.karpenkov
Date: Fri Feb 9 16:38:21 2018
New Revision: 324788
URL: http://llvm.org/viewvc/llvm-project?rev=324788&view=rev
Log:
Make LLVM timer reprintable: that is, make more than one print action on the same timer feasible
Currently, each LLVM timer can be only printed once, as the act of
printing clears the timer.
Moreover, the current printing mechanism implicitly assumes that the
timer is stopped -- and prints zero otherwise.
This patch relaxes this assumption and makes printing statistics
multiple time a possibility.
Differential Revision: https://reviews.llvm.org/D43136
Modified:
llvm/trunk/lib/Support/Timer.cpp
Modified: llvm/trunk/lib/Support/Timer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=324788&r1=324787&r2=324788&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Timer.cpp (original)
+++ llvm/trunk/lib/Support/Timer.cpp Fri Feb 9 16:38:21 2018
@@ -336,10 +336,14 @@ void TimerGroup::prepareToPrintList() {
// reset them.
for (Timer *T = FirstTimer; T; T = T->Next) {
if (!T->hasTriggered()) continue;
+ bool WasRunning = T->isRunning();
+ if (WasRunning)
+ T->stopTimer();
+
TimersToPrint.emplace_back(T->Time, T->Name, T->Description);
- // Clear out the time.
- T->clear();
+ if (WasRunning)
+ T->startTimer();
}
}
@@ -381,6 +385,10 @@ const char *TimerGroup::printJSONValues(
printJSONValue(OS, R, ".user", T.getUserTime());
OS << delim;
printJSONValue(OS, R, ".sys", T.getSystemTime());
+ if (T.getMemUsed()) {
+ OS << delim;
+ printJSONValue(OS, R, ".sys", T.getMemUsed());
+ }
}
TimersToPrint.clear();
return delim;
More information about the llvm-commits
mailing list