Created
February 3, 2017 17:48
-
-
Save puredanger/88d0491cbb4dbf8fe98b3747963d0068 to your computer and use it in GitHub Desktop.
reduce + vs apply +
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def v0 []) | |
(def v10 (vec (range 10))) | |
(def v100 (vec (range 100))) | |
(def v1000 (vec (range 1000))) | |
(quick-bench (reduce + v0)) ;; 2 ns | |
(quick-bench (apply + v0)) ;; 29 ns | |
(quick-bench (reduce + v10)) ;; 216 ns | |
(quick-bench (apply + v10)) ;; 392 ns | |
(quick-bench (reduce + v100)) ;; 2.13 µs | |
(quick-bench (apply + v100)) ;; 2.38 µs | |
(quick-bench (reduce + v1000)) ;; 21.8 µs | |
(quick-bench (apply + v1000)) ;; 22.6 µs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment