aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-12 23:29:28 -0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-12 23:29:28 -0400
commite82767910c649f160d6701e47f606f3b8dde4b29 (patch)
treea951e469b37adfe3db1485a0bc8996ac4cc51416 /src/libexpr/eval.hh
parent325d1cfebf6c8ad391dc318f984feb3e5731aa5a (diff)
Add some basic profiling support to the evaluator
Setting the environment variable NIX_COUNT_CALLS to 1 enables some basic profiling in the evaluator. It will count calls to functions and primops as well as evaluations of attributes. For example, to see where evaluation of a NixOS configuration spends its time: $ NIX_SHOW_STATS=1 NIX_COUNT_CALLS=1 ./src/nix-instantiate/nix-instantiate '<nixos>' -A system --readonly-mode ... calls to 39 primops: 239532 head 233962 tail 191252 hasAttr ... calls to 1595 functions: 224157 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/lists.nix:17:19' 221767 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/lists.nix:17:14' 221767 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/lists.nix:17:10' ... evaluations of 7088 attributes: 167377 undefined position 132459 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/attrsets.nix:119:41' 47322 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/attrsets.nix:13:21' ...
Diffstat (limited to 'src/libexpr/eval.hh')
-rw-r--r--src/libexpr/eval.hh16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index 5103ae8ce..540f1e200 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -244,9 +244,21 @@ private:
unsigned long nrAttrsets;
unsigned long nrOpUpdates;
unsigned long nrOpUpdateValuesCopied;
-
- friend class RecursionCounter;
+
+ bool countCalls;
+
+ typedef std::map<Symbol, unsigned int> PrimOpCalls;
+ PrimOpCalls primOpCalls;
+
+ typedef std::map<Pos, unsigned int> FunctionCalls;
+ FunctionCalls functionCalls;
+
+ typedef std::map<Pos, unsigned int> AttrSelects;
+ AttrSelects attrSelects;
+
friend class ExprOpUpdate;
+ friend class ExprSelect;
+ friend void prim_getAttr(EvalState & state, Value * * args, Value & v);
};