Created
August 28, 2013 15:35
-
-
Save gfredericks/6367436 to your computer and use it in GitHub Desktop.
deftype is 6 times slower than vectors?
This file contains hidden or 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
(ns deftypes.are.slow | |
(:use criterium.core)) | |
(deftype Pair [a b]) | |
(bench | |
(->> (range 100000) | |
(map #(vector % (inc %))) | |
(map second) | |
(apply +))) | |
;; WARNING: Final GC required 5.277774812522496 % of runtime | |
;; Evaluation count : 1200 in 60 samples of 20 calls. | |
;; Execution time mean : 45.895915 ms | |
;; Execution time std-deviation : 1.654094 ms | |
;; Execution time lower quantile : 43.937738 ms ( 2.5%) | |
;; Execution time upper quantile : 49.875242 ms (97.5%) | |
;; Overhead used : 13.796370 ns | |
;; | |
;; Found 2 outliers in 60 samples (3.3333 %) | |
;; low-severe 2 (3.3333 %) | |
;; Variance from outliers : 22.2418 % Variance is moderately inflated by outliers | |
(bench | |
(->> (range 100000) | |
(map #(Pair. % (inc %))) | |
(map #(.b %)) | |
(apply +))) | |
;; Evaluation count : 240 in 60 samples of 4 calls. | |
;; Execution time mean : 285.409938 ms | |
;; Execution time std-deviation : 17.054052 ms | |
;; Execution time lower quantile : 267.066433 ms ( 2.5%) | |
;; Execution time upper quantile : 326.247203 ms (97.5%) | |
;; Overhead used : 13.796370 ns | |
;; | |
;; Found 6 outliers in 60 samples (10.0000 %) | |
;; low-severe 4 (6.6667 %) | |
;; low-mild 2 (3.3333 %) | |
;; Variance from outliers : 45.0782 % Variance is moderately inflated by outliers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For posterity: the issue is reflection on line 26.