[llvm-commits] [llvm] r99841 - in /llvm/trunk: include/llvm/Support/Timer.h lib/Support/Timer.cpp

Chris Lattner sabre at nondot.org
Mon Mar 29 14:28:41 PDT 2010


Author: lattner
Date: Mon Mar 29 16:28:41 2010
New Revision: 99841

URL: http://llvm.org/viewvc/llvm-project?rev=99841&view=rev
Log:
remove support for per-time peak memory tracking, this
isn't used by anyone and is better exposed as a non-per-timer 
thing.  Also, stop including System/Mutex.h in Timer.h

Modified:
    llvm/trunk/include/llvm/Support/Timer.h
    llvm/trunk/lib/Support/Timer.cpp

Modified: llvm/trunk/include/llvm/Support/Timer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Timer.h?rev=99841&r1=99840&r2=99841&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Timer.h (original)
+++ llvm/trunk/include/llvm/Support/Timer.h Mon Mar 29 16:28:41 2010
@@ -16,7 +16,6 @@
 #define LLVM_SUPPORT_TIMER_H
 
 #include "llvm/System/DataTypes.h"
-#include "llvm/System/Mutex.h"
 #include <string>
 #include <vector>
 #include <cassert>
@@ -39,8 +38,6 @@
   double UserTime;       // User time elapsed
   double SystemTime;     // System time elapsed
   ssize_t MemUsed;       // Memory allocated (in bytes)
-  size_t PeakMem;        // Peak memory used
-  size_t PeakMemBase;    // Temporary for peak memory calculation.
   std::string Name;      // The name of this time variable.
   bool Started;          // Has this time variable ever been started?
   TimerGroup *TG;        // The TimerGroup this Timer is in.
@@ -54,7 +51,6 @@
   double getProcessTime() const { return UserTime+SystemTime; }
   double getWallTime() const { return Elapsed; }
   ssize_t getMemUsed() const { return MemUsed; }
-  size_t getPeakMem() const { return PeakMem; }
 public:
   std::string getName() const { return Name; }
 
@@ -77,12 +73,6 @@
   ///
   void stopTimer();
 
-  /// addPeakMemoryMeasurement - This method should be called whenever memory
-  /// usage needs to be checked.  It adds a peak memory measurement to the
-  /// currently active timers, which will be printed when the timer group prints
-  ///
-  static void addPeakMemoryMeasurement();
-
   /// print - Print the current timer to standard error, and reset the "Started"
   /// flag.
   void print(const Timer &Total, raw_ostream &OS);

Modified: llvm/trunk/lib/Support/Timer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99841&r1=99840&r2=99841&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Timer.cpp (original)
+++ llvm/trunk/lib/Support/Timer.cpp Mon Mar 29 16:28:41 2010
@@ -11,15 +11,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Support/Debug.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Format.h"
+#include "llvm/System/Mutex.h"
 #include "llvm/System/Process.h"
-#include <algorithm>
-#include <functional>
 #include <map>
 using namespace llvm;
 
@@ -76,13 +75,13 @@
 //===----------------------------------------------------------------------===//
 
 Timer::Timer(const std::string &N)
-  : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), PeakMem(0), Name(N),
+  : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), Name(N),
     Started(false), TG(getDefaultTimerGroup()) {
   TG->addTimer();
 }
 
 Timer::Timer(const std::string &N, TimerGroup &tg)
-  : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), PeakMem(0), Name(N),
+  : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), Name(N),
     Started(false), TG(&tg) {
   TG->addTimer();
 }
@@ -154,7 +153,6 @@
   UserTime   -= TR.UserTime;
   SystemTime -= TR.SystemTime;
   MemUsed    -= TR.MemUsed;
-  PeakMemBase = TR.MemUsed;
 }
 
 void Timer::stopTimer() {
@@ -179,7 +177,6 @@
   UserTime   += T.UserTime;
   SystemTime += T.SystemTime;
   MemUsed    += T.MemUsed;
-  PeakMem    += T.PeakMem;
 }
 
 const Timer &Timer::operator=(const Timer &T) {
@@ -187,8 +184,6 @@
   UserTime = T.UserTime;
   SystemTime = T.SystemTime;
   MemUsed = T.MemUsed;
-  PeakMem = T.PeakMem;
-  PeakMemBase = T.PeakMemBase;
   Name = T.Name;
   Started = T.Started;
   assert(TG == T.TG && "Can only assign timers in the same TimerGroup!");
@@ -196,18 +191,6 @@
 }
 
 
-/// addPeakMemoryMeasurement - This method should be called whenever memory
-/// usage needs to be checked.  It adds a peak memory measurement to the
-/// currently active timers, which will be printed when the timer group prints
-///
-void Timer::addPeakMemoryMeasurement() {
-  size_t MemUsed = getMemUsage();
-  for (std::vector<Timer*>::iterator I = ActiveTimers->begin(),
-         E = ActiveTimers->end(); I != E; ++I)
-    (*I)->PeakMem = std::max((*I)->PeakMem, MemUsed-(*I)->PeakMemBase);
-}
-
-
 static void printVal(double Val, double Total, raw_ostream &OS) {
   if (Total < 1e-7)   // Avoid dividing by zero.
     OS << "        -----     ";
@@ -231,12 +214,6 @@
   if (Total.MemUsed)
     OS << format("%9lld", (long long)MemUsed) << "  ";
 
-  if (Total.PeakMem) {
-    if (PeakMem)
-      OS << format("%9lld", (long long)PeakMem) << "  ";
-    else
-      OS << "           ";
-  }
   OS << Name << "\n";
   
   Started = false;  // Once printed, don't print again
@@ -364,8 +341,6 @@
     *OutStream << "   ---Wall Time---";
     if (Total.getMemUsed())
       *OutStream << "  ---Mem---";
-    if (Total.getPeakMem())
-      *OutStream << "  -PeakMem-";
     *OutStream << "  --- Name ---\n";
 
     // Loop through all of the timing data, printing it out.





More information about the llvm-commits mailing list