diff options
author | Chris Lattner <sabre@nondot.org> | 2003-01-30 23:08:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-01-30 23:08:50 +0000 |
commit | 3f39849003689a4d33aecdc744d4d27fd93a8f68 (patch) | |
tree | 2b3859c297191e3e570627424b1cb3f1bb64e074 /support | |
parent | 49f201214055c8eaffa3eef91b87c4997afadc45 (diff) | |
download | external_llvm-3f39849003689a4d33aecdc744d4d27fd93a8f68.zip external_llvm-3f39849003689a4d33aecdc744d4d27fd93a8f68.tar.gz external_llvm-3f39849003689a4d33aecdc744d4d27fd93a8f68.tar.bz2 |
* 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
Diffstat (limited to 'support')
-rw-r--r-- | support/lib/Support/Timer.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/support/lib/Support/Timer.cpp b/support/lib/Support/Timer.cpp index 17fea8b..8023c50 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 { |