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

llvm-svn: 99841
This commit is contained in:
Chris Lattner 2010-03-29 21:28:41 +00:00
parent 742db6874a
commit 09a4074869
2 changed files with 4 additions and 39 deletions

View File

@ -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 @@ class Timer {
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 @@ private:
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 @@ public:
///
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);

View File

@ -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 @@ static TimerGroup *getDefaultTimerGroup() {
//===----------------------------------------------------------------------===//
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 @@ void Timer::startTimer() {
UserTime -= TR.UserTime;
SystemTime -= TR.SystemTime;
MemUsed -= TR.MemUsed;
PeakMemBase = TR.MemUsed;
}
void Timer::stopTimer() {
@ -179,7 +177,6 @@ void Timer::sum(const Timer &T) {
UserTime += T.UserTime;
SystemTime += T.SystemTime;
MemUsed += T.MemUsed;
PeakMem += T.PeakMem;
}
const Timer &Timer::operator=(const Timer &T) {
@ -187,8 +184,6 @@ const Timer &Timer::operator=(const Timer &T) {
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 @@ const Timer &Timer::operator=(const Timer &T) {
}
/// 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 @@ void Timer::print(const Timer &Total, raw_ostream &OS) {
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 @@ void TimerGroup::removeTimer() {
*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.