Performance of `instance-precondition` on JVM
Opened this issue · 0 comments
frenchy64 commented
Clojure compiles (let [cls String] (instance? klass "a"))
less optimally than (instance? String "a")
. This affects this line, which I imagine is a pretty hot code path in schema usage:
schema/src/cljc/schema/core.cljc
Line 166 in 8fcb57f
The perf difference seems roughly 2x.
examples.server=> (time (dotimes [_ 10000] (let [cls String] (instance? cls "a"))))
"Elapsed time: 1.142388 msecs"
nil
examples.server=> (time (dotimes [_ 10000] (instance? String "a")))
"Elapsed time: 0.411797 msecs"
nil