First, the alphabet-macro is wrong, it should use name instead of str in comp:
user=> (macroexpand-1 '(alphabet-macro)) (do (clojure.core/defrecord Alphabet [:a :b :c :d :e :f :g :h :i :j :k :l :m :n :o :p :q :r :s :t :u :w :v :x :y :z]) (def dummy-record (Alphabet. 0 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))) user=> (get dummy-record :a) nil fixed it with name: (defmacro alphabet-macro [] `(do (defrecord ~'Alphabet [~@(map (comp symbol name) a-z-ks)]) (def ~'dummy-record (~'Alphabet. ~@(range 26))))) (alphabet-macro) user=> (macroexpand-1 '(alphabet-macro)) (do (clojure.core/defrecord Alphabet [a b c d e f g h i j k l m n o p q r s t u w v x y z]) (def dummy-record (Alphabet. 0 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))) user=> (get dummy-record :a) 0 After fixed, the benchmark result is as expected. 2017-10-08 16:40 GMT+08:00 Jiacai Liu <jiacai2...@gmail.com>: > As I read JoyOfClojure, it says one of reasons that prefer record over > plain map is speed, out of curiosity I test this using > https://github.com/hugoduncan/criterium, but the result is just contrary > to my expectation. record is slower than map. Is there any optimizations > made to clojure 1.8.0 ? > > test code: https://gist.github.com/jiacai2050/ > cdaaffa93079a4b8451727ace0c13064 > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 庄晓丹 Email: killme2...@gmail.com Site: http://fnil.net 不学习,毋宁死 -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.