summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-02-27 17:28:51 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-02-27 17:28:51 +0000
commitadce01a8d05ee21890a5be699a26f1835594cb5d (patch)
tree0fbe9e3b50c6db89923fbbe45293a2f1762e36a6 /src
parent363e307fd360c32a932b9bcb1d620d3add259f79 (diff)
downloadguix-adce01a8d05ee21890a5be699a26f1835594cb5d.tar.gz
* When NIX_SHOW_STATS=1, show the amount of stack space consumed by
  the Nix expression evaluator.

Diffstat (limited to 'src')
-rw-r--r--src/libexpr/eval.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index cccd40404c..6e78f00f51 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -362,8 +362,14 @@ Expr autoCallFunction(Expr e, const ATermMap & args)
 }
 
 
+static char * deepestStack = (char *) -1; /* for measuring stack usage */
+
+
 Expr evalExpr2(EvalState & state, Expr e)
 {
+    char x;
+    if (&x < deepestStack) deepestStack = &x;
+    
     Expr e1, e2, e3, e4;
     ATerm name, pos;
     AFun sym = ATgetAFun(e);
@@ -752,12 +758,14 @@ extern "C" {
 
 void printEvalStats(EvalState & state)
 {
+    char x;
     bool showStats = getEnv("NIX_SHOW_STATS", "0") != "0";
     printMsg(showStats ? lvlInfo : lvlDebug,
-        format("evaluated %1% expressions, %2% cache hits, %3%%% efficiency, used %4% ATerm bytes")
+        format("evaluated %1% expressions, %2% cache hits, %3%%% efficiency, used %4% ATerm bytes, used %5% bytes of stack space")
         % state.nrEvaluated % state.nrCached
         % ((float) state.nrCached / (float) state.nrEvaluated * 100)
-        % AT_calcAllocatedSize());
+        % AT_calcAllocatedSize()
+        % (&x - deepestStack));
     if (showStats)
         printATermMapStats();
 }