summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Timer.cpp
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
commit2f75204cf40b077ce4a5c5018ac730d4e8b25d79 (patch)
treebd38bbded0611c46b244f849574593f42ddbf435 /llvm/lib/Support/Timer.cpp
parent68f63f779c1e19007bb1d3efc70c246ff67dc606 (diff)
downloadbcm5719-llvm-2f75204cf40b077ce4a5c5018ac730d4e8b25d79.tar.gz
bcm5719-llvm-2f75204cf40b077ce4a5c5018ac730d4e8b25d79.zip
* 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. llvm-svn: 5448
Diffstat (limited to 'llvm/lib/Support/Timer.cpp')
-rw-r--r--llvm/lib/Support/Timer.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp
index 17fea8b93c8..8023c500e5d 100644
--- a/llvm/lib/Support/Timer.cpp
+++ b/llvm/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 {
OpenPOWER on IntegriCloud