1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

* 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
This commit is contained in:
Chris Lattner 2003-01-30 23:08:50 +00:00
parent dcf38586ef
commit bedb4f4a83
2 changed files with 28 additions and 4 deletions

View File

@ -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 {

View File

@ -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 {