From adce01a8d05ee21890a5be699a26f1835594cb5d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 27 Feb 2007 17:28:51 +0000 Subject: * When NIX_SHOW_STATS=1, show the amount of stack space consumed by the Nix expression evaluator. --- src/libexpr/eval.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/libexpr') diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index cccd40404..6e78f00f5 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(); } -- cgit v1.2.3