[llvm-commits] CVS: llvm/lib/Support/Timer.cpp
    Chris Lattner 
    lattner at cs.uiuc.edu
       
    Thu Jan 30 17:10:02 PST 2003
    
    
  
Changes in directory llvm/lib/Support:
Timer.cpp updated: 1.10 -> 1.11
---
Log message:
* 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.
---
Diffs of the changes:
Index: llvm/lib/Support/Timer.cpp
diff -u llvm/lib/Support/Timer.cpp:1.10 llvm/lib/Support/Timer.cpp:1.11
--- llvm/lib/Support/Timer.cpp:1.10	Mon Nov 18 15:47:09 2002
+++ llvm/lib/Support/Timer.cpp	Thu Jan 30 17:08:50 2003
@@ -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 @@
 }
 
 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 {
    
    
More information about the llvm-commits
mailing list