diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2007-02-27T17·28+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2007-02-27T17·28+0000 |
commit | adce01a8d05ee21890a5be699a26f1835594cb5d (patch) | |
tree | 0fbe9e3b50c6db89923fbbe45293a2f1762e36a6 /src/libexpr/eval.cc | |
parent | 363e307fd360c32a932b9bcb1d620d3add259f79 (diff) |
* When NIX_SHOW_STATS=1, show the amount of stack space consumed by
the Nix expression evaluator.
Diffstat (limited to '')
-rw-r--r-- | src/libexpr/eval.cc | 12 |
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(); } |