This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-30
Channels
- # admin-announcements (11)
- # announcements (1)
- # beginners (1)
- # boot (247)
- # cider (15)
- # clara (16)
- # cljs-dev (14)
- # clojure (118)
- # clojure-czech (10)
- # clojure-ecuador (1)
- # clojure-japan (1)
- # clojure-russia (22)
- # clojurescript (57)
- # data-science (12)
- # datomic (2)
- # devcards (1)
- # editors-rus (2)
- # emacs (1)
- # events (2)
- # funcool (1)
- # hoplon (37)
- # juxt (1)
- # ldnclj (2)
- # leiningen (1)
- # nginx (12)
- # off-topic (16)
- # om (361)
- # onyx (34)
- # re-frame (3)
- # spacemacs (9)
- # yada (43)
A friend of mine wanted to compare benchmark times for summing a 1e9 collection of ones, between R and Clojure, just for fun. In R, it is
x <- rep(1,1e9)
system.time( { s<- sum(x) })
R: 1.278 user, 0 system 1.279 elapsed
roughly. The best clojure equivalent I came up with so far was (require '[hiphip.int :as hiphip])
(def x (let [v (vec (range 1e9))] (hiphip/amake [i 1e9] 1)))
user=> (time (hiphip/asum x))
"Elapsed time: 2854.957051 msecs"
1000000000
but perhaps someone knows an even better way. Would core.matrix
be faster? We realize of course that benchmarks are often silly, but in the spirit of fun, can we think up a better way?