clojure.lang.IFn.That being, it's really rather slow.
Using an AABB tree-node I've been messing with, extracting a single argument from a node defined with
defrecord 106 times takes roughly:| Time | Form |
|---|---|
| 15 ms | (:key node) |
| 135 ms | (node :key) (that is, implementing IFn using get) |
| 85 ms | (let [{:keys [key]} node] ...) |
Fascinating stuff. But that's definitely a large enough improvment that I'll be stripping out the implementation of
invoke, and be more aggressive promoting ad-hoc maps to records in future! It's hard to say no to an order of magnitude improvement.Edit: I don't mean that
clojure.lang.IFn is necessarily slow, just that it seems the (:key record) form is faster than (get record :key). I'm assuming this is due to directly mapping the former to member access, whilst the latter has to use some combination of additional reflection and the hash map implementation to get the value.