diff options
Diffstat (limited to 'lib/Support/Timer.cpp')
-rw-r--r-- | lib/Support/Timer.cpp | 16 |
1 files changed, 14 insertions, 2 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 { |