Open frenchy64 opened 4 months ago
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:
(let [cls String] (instance? klass "a"))
(instance? String "a")
https://github.com/plumatic/schema/blob/8fcb57f87ffe74185e1f1da72be4933bd4aad4d2/src/cljc/schema/core.cljc#L166
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
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:https://github.com/plumatic/schema/blob/8fcb57f87ffe74185e1f1da72be4933bd4aad4d2/src/cljc/schema/core.cljc#L166
The perf difference seems roughly 2x.