diff options
author | Vincent Ambo <mail@tazj.in> | 2020-12-23T12·36+0100 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2020-12-23T12·44+0000 |
commit | 73e9265f954528b6b2eccf98572e77126539a8df (patch) | |
tree | 48a1e093761e86c5e605d074e8c4d5f1bb64f1b1 /third_party/immer/tools/clojure/src/immer_benchmark.clj | |
parent | f7ea650142eb796eb3f2827c805cc0bc563e2183 (diff) |
chore(3p/immer): Remove vendored copy of immer r/2029
We ended up dropping the use of this library again. Change-Id: I2c44cd22a6128d23f87a582402bf5fb84991d608 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2292 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'third_party/immer/tools/clojure/src/immer_benchmark.clj')
-rw-r--r-- | third_party/immer/tools/clojure/src/immer_benchmark.clj | 131 |
1 files changed, 0 insertions, 131 deletions
diff --git a/third_party/immer/tools/clojure/src/immer_benchmark.clj b/third_party/immer/tools/clojure/src/immer_benchmark.clj deleted file mode 100644 index f3d6f73e6c18..000000000000 --- a/third_party/immer/tools/clojure/src/immer_benchmark.clj +++ /dev/null @@ -1,131 +0,0 @@ -(ns immer-benchmark - (:require [criterium.core :as c] - [clojure.core.rrb-vector :as fv])) - -(defn h0 [& args] - (apply println "\n####" args)) - -(defn h1 [& args] - (apply println "\n====" args)) - -(defn h2 [& args] - (apply println "\n----" args)) - -(defn run-benchmarks [N S] - (h0 "Running benchmarks: N =" N " S =" S) - - (def c-steps 10) - - (defn vector-push-f [v] - (loop [v v - i 0] - (if (< i N) - (recur (fv/catvec (fv/vector i) v) - (inc i)) - v))) - - (defn vector-push [v] - (loop [v v - i 0] - (if (< i N) - (recur (conj v i) - (inc i)) - v))) - - (defn vector-push! [v] - (loop [v (transient v) - i 0] - (if (< i N) - (recur (conj! v i) - (inc i)) - (persistent! v)))) - - (defn vector-concat [v vc] - (loop [v v - i 0] - (if (< i c-steps) - (recur (fv/catvec v vc) - (inc i)) - v))) - - (defn vector-update [v] - (loop [v v - i 0] - (if (< i N) - (recur (assoc v i (+ i 1)) - (inc i)) - v))) - - (defn vector-update-random [v] - (loop [v v - i 0] - (if (< i N) - (recur (assoc v (rand-int N) i) - (inc i)) - v))) - - (defn vector-update! [v] - (loop [v (transient v) - i 0] - (if (< i N) - (recur (assoc! v i (+ i 1)) - (inc i)) - (persistent! v)))) - - (defn vector-update-random! [v] - (loop [v (transient v) - i 0] - (if (< i N) - (recur (assoc! v (rand-int N) i) - (inc i)) - (persistent! v)))) - - (defn vector-iter [v] - (reduce + 0 v)) - - (defn the-benchmarks [empty-v] - (def full-v (into empty-v (range N))) - (h2 "iter") - (c/bench (vector-iter full-v) :samples S) - (if (> N 100000) - (h2 "skipping updates 'cuz N > 100000 (would run out of mem)") - (do - (h2 "update!") - (c/bench (vector-update! full-v) :samples S) - (h2 "update-random!") - (c/bench (vector-update-random! full-v) :samples S) - (h2 "push!") - (c/bench (vector-push! empty-v) :samples S) - (h2 "update") - (c/bench (vector-update full-v) :samples S) - (h2 "update-random") - (c/bench (vector-update-random full-v) :samples S) - (h2 "push") - (c/bench (vector-push empty-v) :samples S)))) - - (defn the-rrb-benchmarks [empty-v] - (if (> N 1000) - (h2 "skipping relaxed test 'cuz N > 1000 (rrb-vector bug)") - (do - (def full-v (vector-push-f empty-v)) - (h2 "iter/f") - (c/bench (vector-iter full-v) :samples S) - (h2 "update/f") - (c/bench (vector-update full-v) :samples S) - (h2 "update-random/f") - (c/bench (vector-update-random full-v) :samples S))) - (def short-v (into empty-v (range (/ N c-steps)))) - (h2 "concat") - (c/bench (vector-concat empty-v short-v)) :samples S) - - (h1 "vector") - (the-benchmarks (vector)) - - (h1 "rrb-vector") - (the-benchmarks (fv/vector)) - (the-rrb-benchmarks (fv/vector))) - -(defn -main [] - (run-benchmarks 1000 100) - (run-benchmarks 100000 20) - (run-benchmarks 10000000 3)) |