plumatic/schema

Performance of `instance-precondition` on JVM

Opened this issue · 0 comments

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:

#?(:clj #(instance? klass %)

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