Skip to content

Instantly share code, notes, and snippets.

@ghadishayban
Created April 1, 2014 20:18
Show Gist options
  • Save ghadishayban/9922263 to your computer and use it in GitHub Desktop.
Save ghadishayban/9922263 to your computer and use it in GitHub Desktop.
pathological fold performance
(ns foldtest
(:require [clojure.core.reducers :as r]))
;; redefined to parameterize the threshold to r/fold
(defn foldcat [n coll]
(r/fold n r/cat r/append! coll))
(defn benchmark [n]
(let [x (into [] (range 1e8))]
(println "init vec")
(dotimes [_ n]
(time (foldcat 4096 (r/map inc x))))))
(defn -main [n]
(benchmark (Long/parseLong n)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment