about summary refs log tree commit diff
path: root/src/libexpr
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr')
-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 cccd40404c17..6e78f00f511a 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();
 }