From 2f75204cf40b077ce4a5c5018ac730d4e8b25d79 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 30 Jan 2003 23:08:50 +0000 Subject: * 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 --- llvm/support/lib/Support/Timer.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'llvm/support/lib') diff --git a/llvm/support/lib/Support/Timer.cpp b/llvm/support/lib/Support/Timer.cpp index 17fea8b93c8..8023c500e5d 100644 --- a/llvm/support/lib/Support/Timer.cpp +++ b/llvm/support/lib/Support/Timer.cpp @@ -5,6 +5,7 @@ //===----------------------------------------------------------------------===// #include "Support/Timer.h" +#include "Support/CommandLine.h" #include #include #include @@ -15,6 +16,13 @@ #include #include +namespace { + cl::opt + 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 { -- cgit v1.2.3