aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-03-25 16:35:24 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-03-25 16:35:24 +0000
commit8da118e4d03a9ecbd2116eadabd992cfef0479c5 (patch)
treef67bcb5504805d5f5bff662c835c5bce0f3a859f
parentc2ba4313fb7f2e257f6205eb3fa366376c3010b0 (diff)
* Measure stack usage.
-rw-r--r--src/libexpr/eval-test.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/libexpr/eval-test.cc b/src/libexpr/eval-test.cc
index c40912c13..649c5e020 100644
--- a/src/libexpr/eval-test.cc
+++ b/src/libexpr/eval-test.cc
@@ -161,8 +161,14 @@ static Env * allocEnv()
}
+char * p1 = 0, * p2 = 0;
+
+
static void eval(Env * env, Expr e, Value & v)
{
+ char c;
+ if (!p1) p1 = &c; else if (!p2) p2 = &c;
+
printMsg(lvlError, format("eval: %1%") % e);
Sym name;
@@ -333,9 +339,9 @@ static void eval(Env * env, Expr e, Value & v)
if (matchOpConcat(e, e1, e2)) {
Value v1; eval(env, e1, v1);
- if (v1.type != tList) throw TypeError("list expecteed");
+ if (v1.type != tList) throw TypeError("list expected");
Value v2; eval(env, e2, v2);
- if (v2.type != tList) throw TypeError("list expecteed");
+ if (v2.type != tList) throw TypeError("list expected");
v.type = tList;
v.list.length = v1.list.length + v2.list.length;
v.list.elems = new Value[v.list.length];
@@ -347,7 +353,7 @@ static void eval(Env * env, Expr e, Value & v)
v.list.elems[n + v1.list.length] = v2.list.elems[n];
return;
}
-
+
throw Error("unsupported term");
}
@@ -370,6 +376,7 @@ static void strictEval(Env * env, Expr e, Value & v)
void doTest(string s)
{
+ p1 = p2 = 0;
EvalState state;
Expr e = parseExprFromString(state, s, "/");
printMsg(lvlError, format(">>>>> %1%") % e);
@@ -407,6 +414,7 @@ void run(Strings args)
printMsg(lvlError, format("alloced %1% values") % nrValues);
printMsg(lvlError, format("alloced %1% environments") % nrEnvs);
+ printMsg(lvlError, format("each eval() uses %1% bytes of stack space") % (p1 - p2));
}