Created
July 6, 2022 23:43
-
-
Save chenlilyd/3a15e953b436f549b644960b2cb68fc2 to your computer and use it in GitHub Desktop.
profile swap! conj perfromance
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
;; check performance of swap! with conj | |
(require '[clojure.core.async :as a]) | |
(profile {:dynamic? true} | |
(let [ids (atom []) | |
n-ids 2000000 | |
tasks (mapv (fn [i] (a/go (p :swap-conj (swap! ids conj i)))) (range n-ids))] | |
(doseq [t tasks] | |
(a/<!! t)) | |
(assert (= n-ids (count @ids))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the performance is not bad, but it looks like it also requires a lot of memory, which this test does not show