Created
April 1, 2014 20:18
-
-
Save ghadishayban/9922263 to your computer and use it in GitHub Desktop.
pathological fold performance
This file contains hidden or 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
(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