Created
October 8, 2017 08:28
-
-
Save jiacai2050/cdaaffa93079a4b8451727ace0c13064 to your computer and use it in GitHub Desktop.
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
(ns demo.record | |
(:require [criterium.core :refer [bench with-progress-reporting]])) | |
(def a-z-ks (map (comp keyword str) (seq "abcdefghijklmnopqrstuwvxyz"))) | |
(def dummy-map (zipmap a-z-ks (range))) | |
(defmacro alphabet-macro [] | |
`(do | |
(defrecord ~'Alphabet [~@(map (comp symbol str) a-z-ks)]) | |
(def ~'dummy-record (~'Alphabet. ~@(range 26))))) | |
(alphabet-macro) | |
(with-progress-reporting (bench | |
(doseq [k a-z-ks] | |
(get dummy-map k)))) | |
;; Evaluation count : 35047440 in 60 samples of 584124 calls. | |
;; Execution time mean : 1.748119 µs | |
;; Execution time std-deviation : 47.972714 ns | |
;; Execution time lower quantile : 1.691436 µs ( 2.5%) | |
;; Execution time upper quantile : 1.880925 µs (97.5%) | |
;; Overhead used : 2.179973 ns | |
;; Found 3 outliers in 60 samples (5.0000 %) | |
;; low-severe 3 (5.0000 %) | |
;; Variance from outliers : 14.2220 % Variance is moderately inflated by outliers | |
(with-progress-reporting (bench | |
(doseq [k a-z-ks] | |
(get dummy-record k)))) | |
;; Evaluation count : 17245380 in 60 samples of 287423 calls. | |
;; Execution time mean : 3.398654 µs | |
;; Execution time std-deviation : 80.611687 ns | |
;; Execution time lower quantile : 3.286580 µs ( 2.5%) | |
;; Execution time upper quantile : 3.637143 µs (97.5%) | |
;; Overhead used : 2.179973 ns | |
;; Found 3 outliers in 60 samples (5.0000 %) | |
;; low-severe 2 (3.3333 %) | |
;; low-mild 1 (1.6667 %) | |
;; Variance from outliers : 11.0366 % Variance is moderately inflated by outliers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After fix alphabet-macro (change
str
toname
incomp
), the result is as expected