Skip to content
Snippets Groups Projects
Commit a3ddb9b5 authored by Chris Lattner's avatar Chris Lattner
Browse files

Add facility to compute peak memory usage

llvm-svn: 4752
parent 2a254b6a
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,8 @@ class Timer { ...@@ -35,6 +35,8 @@ class Timer {
double UserTime; // User time elapsed double UserTime; // User time elapsed
double SystemTime; // System time elapsed double SystemTime; // System time elapsed
long MemUsed; // Memory allocated (in bytes) long MemUsed; // Memory allocated (in bytes)
long PeakMem; // Peak memory used
long PeakMemBase; // Temporary for peak calculation...
std::string Name; // The name of this time variable std::string Name; // The name of this time variable
bool Started; // Has this time variable ever been started? bool Started; // Has this time variable ever been started?
TimerGroup *TG; // The TimerGroup this Timer is in. TimerGroup *TG; // The TimerGroup this Timer is in.
...@@ -47,6 +49,7 @@ public: ...@@ -47,6 +49,7 @@ public:
double getProcessTime() const { return UserTime+SystemTime; } double getProcessTime() const { return UserTime+SystemTime; }
double getWallTime() const { return Elapsed; } double getWallTime() const { return Elapsed; }
long getMemUsed() const { return MemUsed; } long getMemUsed() const { return MemUsed; }
long getPeakMem() const { return PeakMem; }
std::string getName() const { return Name; } std::string getName() const { return Name; }
const Timer &operator=(const Timer &T) { const Timer &operator=(const Timer &T) {
...@@ -54,6 +57,8 @@ public: ...@@ -54,6 +57,8 @@ public:
UserTime = T.UserTime; UserTime = T.UserTime;
SystemTime = T.SystemTime; SystemTime = T.SystemTime;
MemUsed = T.MemUsed; MemUsed = T.MemUsed;
PeakMem = T.PeakMem;
PeakMemBase = T.PeakMemBase;
Name = T.Name; Name = T.Name;
Started = T.Started; Started = T.Started;
assert (TG == T.TG && "Can only assign timers in the same TimerGroup!"); assert (TG == T.TG && "Can only assign timers in the same TimerGroup!");
...@@ -77,6 +82,12 @@ public: ...@@ -77,6 +82,12 @@ public:
/// ///
void stopTimer(); 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" /// print - Print the current timer to standard error, and reset the "Started"
/// flag. /// flag.
void print(const Timer &Total); void print(const Timer &Total);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment