[PATCH] D43136: Make LLVM timer reprintable: that is, make more than one print action on the same timer feasible

George Karpenkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 9 16:40:45 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL324788: Make LLVM timer reprintable: that is, make more than one print action on theā€¦ (authored by george.karpenkov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43136?vs=133659&id=133717#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43136

Files:
  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
@@ -336,10 +336,14 @@
   // 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 @@
     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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43136.133717.patch
Type: text/x-patch
Size: 868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180210/662f893d/attachment.bin>


More information about the llvm-commits mailing list