Java HotSpot(TM) 64-Bit Server VM 25.5-b02
I've been optimising a piece of code lately, and have come to wonder about the performance of keyword comparison. Specifically, I'm not sure whether the performance I'm seeing is what is expected. The data structures page on clojure.org [1] indicates that keywords "provide very fast equality tests". If I micro-benchmark with criterium, then I find the following:As a baseline, comparing integers with `(= 0 1)` takes around 4ns.Comparing keywords with `(= :plus :minus)` takes around 30ns.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
But if any of these Keyword objects were garbage-collected, I think it would break the parity between identical? and =.
The hash code calculation stuff would add performance value though.
I'm just saying I don't see how point (b) is adding performance gains in the context of what else I've read here.
If the compiler (doesn't seem always possible) or map impl's or something is smart enough to not use clj's basic = impl on keywords though and use its equals directly instead, that'd sound like a win.