diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2012-02-04 13:27:11 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2012-02-04 13:27:11 +0000 |
commit | 2bda12ef3b2b1d9a0fc59324d723e3fa883ab223 (patch) | |
tree | 774f4002ca60ddcf70888d4bff33eb4569e0bae6 /src/libexpr | |
parent | ce86a9a0ae928f8cdbe26021b6b757bf5b9d7693 (diff) |
* Print elapsed evaluation time.
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/eval.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 9ebf6293b..fa31a85a0 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -7,6 +7,8 @@ #include <cstring> #include <unistd.h> +#include <sys/time.h> +#include <sys/resource.h> #if HAVE_BOEHMGC @@ -1279,12 +1281,18 @@ bool EvalState::eqValues(Value & v1, Value & v2) void EvalState::printStats() { - char x; bool showStats = getEnv("NIX_SHOW_STATS", "0") != "0"; Verbosity v = showStats ? lvlInfo : lvlDebug; printMsg(v, "evaluation statistics:"); + + struct rusage buf; + getrusage(RUSAGE_SELF, &buf); + float cpuTime = buf.ru_utime.tv_sec + ((float) buf.ru_utime.tv_usec / 1000000); + + printMsg(v, format(" time elapsed: %1%") % cpuTime); printMsg(v, format(" size of a value: %1%") % sizeof(Value)); printMsg(v, format(" expressions evaluated: %1%") % nrEvaluated); + char x; printMsg(v, format(" stack space used: %1% bytes") % (&x - deepestStack)); printMsg(v, format(" max eval() nesting depth: %1%") % maxRecursionDepth); printMsg(v, format(" stack space per eval() level: %1% bytes") |