summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-01-30 23:08:50 +0000
committerChris Lattner <sabre@nondot.org>2003-01-30 23:08:50 +0000
commit3f39849003689a4d33aecdc744d4d27fd93a8f68 (patch)
tree2b3859c297191e3e570627424b1cb3f1bb64e074
parent49f201214055c8eaffa3eef91b87c4997afadc45 (diff)
downloadllvm-3f39849003689a4d33aecdc744d4d27fd93a8f68.tar.gz
llvm-3f39849003689a4d33aecdc744d4d27fd93a8f68.tar.bz2
llvm-3f39849003689a4d33aecdc744d4d27fd93a8f68.tar.xz
* Add new -track-memory option to tools which enables the mem usage column in the reports.
This is now optional (and defaults to off) because mallinfo can be VERY slow as it seems to touch every page of allocated memory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5448 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Support/Timer.cpp16
-rw-r--r--support/lib/Support/Timer.cpp16
2 files changed, 28 insertions, 4 deletions
diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp
index 17fea8b93c..8023c500e5 100644
--- a/lib/Support/Timer.cpp
+++ b/lib/Support/Timer.cpp
@@ -5,6 +5,7 @@
//===----------------------------------------------------------------------===//
#include "Support/Timer.h"
+#include "Support/CommandLine.h"
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/unistd.h>
@@ -15,6 +16,13 @@
#include <algorithm>
#include <functional>
+namespace {
+ cl::opt<bool>
+ TrackSpace("track-memory", cl::desc("Enable -time-passes memory "
+ "tracking (this may be slow)"),
+ cl::Hidden);
+}
+
// getNumBytesToNotCount - This function is supposed to return the number of
// bytes that are to be considered not allocated, even though malloc thinks they
// are allocated.
@@ -65,8 +73,12 @@ Timer::~Timer() {
}
static long getMemUsage() {
- struct mallinfo MI = mallinfo();
- return MI.uordblks/*+MI.hblkhd-getNumBytesToNotCount()*/;
+ if (TrackSpace) {
+ struct mallinfo MI = mallinfo();
+ return MI.uordblks/*+MI.hblkhd-getNumBytesToNotCount()*/;
+ } else {
+ return 0;
+ }
}
struct TimeRecord {
diff --git a/support/lib/Support/Timer.cpp b/support/lib/Support/Timer.cpp
index 17fea8b93c..8023c500e5 100644
--- a/support/lib/Support/Timer.cpp
+++ b/support/lib/Support/Timer.cpp
@@ -5,6 +5,7 @@
//===----------------------------------------------------------------------===//
#include "Support/Timer.h"
+#include "Support/CommandLine.h"
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/unistd.h>
@@ -15,6 +16,13 @@
#include <algorithm>
#include <functional>
+namespace {
+ cl::opt<bool>
+ TrackSpace("track-memory", cl::desc("Enable -time-passes memory "
+ "tracking (this may be slow)"),
+ cl::Hidden);
+}
+
// getNumBytesToNotCount - This function is supposed to return the number of
// bytes that are to be considered not allocated, even though malloc thinks they
// are allocated.
@@ -65,8 +73,12 @@ Timer::~Timer() {
}
static long getMemUsage() {
- struct mallinfo MI = mallinfo();
- return MI.uordblks/*+MI.hblkhd-getNumBytesToNotCount()*/;
+ if (TrackSpace) {
+ struct mallinfo MI = mallinfo();
+ return MI.uordblks/*+MI.hblkhd-getNumBytesToNotCount()*/;
+ } else {
+ return 0;
+ }
}
struct TimeRecord {