Fork me on GitHub
#clojure-dev
<
2017-10-21
>
ikitommi20:10:56

Hi. Is there a perf suite for the Clojure internals? I’m trying to learn how to write fast libraries for Clojure, and now looking for quick wins on the Clojure core itself.

ikitommi20:10:05

Currently just running criterium locally with -server -Xmx4096m JVM settings.

ikitommi20:10:08

looking at https://dev.clojure.org/jira/browse/CLJ-1517, not sure if the microbenchmarks are showing the real thing.

ikitommi20:10:08

One quick win would be to make destructuring less costly. Current:

(defrecord XY [x y])

(def a-map {:x 1, :y 2})
(def a-record (map->XY a-map))

;; 59ns
(cc/quick-bench
  (let [{:keys [x y]} a-map]
    [x y]))

;; 61ns
(cc/quick-bench
  (let [{:keys [x y]} a-record]
    [x y]))

ikitommi20:10:37

My current branch:

;; 30ns
(cc/quick-bench
  (let' [{:keys [x y]} a-map]
        [x y]))

;; 17ns
(cc/quick-bench
  (let' [{:keys [x y]} a-record]
        [x y]))

ikitommi21:10:20

Should I just embed the local criterium results into the jira issue or should I also add a leiningen perf profile with the perf tests into the proposed patch?