We're updating the issue view to help you get more done. 

Optimize keyword function

Description

keyword function can be sped up. This matters when keywords are created dynamically when doing XHR.

The patch now matches Clojure more closely (using substring). It's also optimized for passing strings.

Results:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 (enable-console-print!) (let [sims 1000000] (dotimes [_ 2] (doseq [x ["foo" "foo/bar" [nil "foo"] ["foo" "bar"] [:foo :bar] [nil :foo]]] (prn "Testing keyword with: " x) (if (vector? x) (do (simple-benchmark [[a0 a1] x] (set! js/FOOO (keyword a0 a1)) sims) (simple-benchmark [[a0 a1] x] (set! js/FOOO (keyword2 a0 a1)) sims)) (do (simple-benchmark [] (set! js/FOOO (keyword x)) sims) (simple-benchmark [] (set! js/FOOO (keyword2 x)) sims)))))) "Testing keyword with: " "foo" [], (set! js/FOOO (keyword x)), 1000000 runs, 194 msecs [], (set! js/FOOO (keyword2 x)), 1000000 runs, 71 msecs "Testing keyword with: " "foo/bar" [], (set! js/FOOO (keyword x)), 1000000 runs, 260 msecs [], (set! js/FOOO (keyword2 x)), 1000000 runs, 104 msecs "Testing keyword with: " [nil "foo"] [[a0 a1] x], (set! js/FOOO (keyword a0 a1)), 1000000 runs, 278 msecs [[a0 a1] x], (set! js/FOOO (keyword2 a0 a1)), 1000000 runs, 188 msecs "Testing keyword with: " ["foo" "bar"] [[a0 a1] x], (set! js/FOOO (keyword a0 a1)), 1000000 runs, 379 msecs [[a0 a1] x], (set! js/FOOO (keyword2 a0 a1)), 1000000 runs, 215 msecs "Testing keyword with: " [:foo :bar] [[a0 a1] x], (set! js/FOOO (keyword a0 a1)), 1000000 runs, 351 msecs [[a0 a1] x], (set! js/FOOO (keyword2 a0 a1)), 1000000 runs, 207 msecs "Testing keyword with: " [nil :foo] [[a0 a1] x], (set! js/FOOO (keyword a0 a1)), 1000000 runs, 376 msecs [[a0 a1] x], (set! js/FOOO (keyword2 a0 a1)), 1000000 runs, 37 msecs

Environment

None

Status

Assignee

David Nolen

Reporter

Andre R

Labels

Approval

Accepted

Patch

Code

Affects versions

1.9.562

Priority

Minor