Skip to content

Instantly share code, notes, and snippets.

@semaperepelitsa
Created February 13, 2017 19:53
Show Gist options
  • Save semaperepelitsa/79576063f449621f9a452ae3edb0529a to your computer and use it in GitHub Desktop.
Save semaperepelitsa/79576063f449621f9a452ae3edb0529a to your computer and use it in GitHub Desktop.
simple-benchmark clojurescript example
; Compare vector vs list:
cljs.user=> (simple-benchmark [nums (into (vector) (range 9999))] (nth nums 5000) 1000)
[nums (into (vector) (range 9999))], (nth nums 5000), 1000 runs, 2 msecs
nil
cljs.user=> (simple-benchmark [nums (into (list) (range 9999))] (nth nums 5000) 1000)
[nums (into (list) (range 9999))], (nth nums 5000), 1000 runs, 240 msecs
nil
; It looks similar to let:
cljs.user=> (let [nums (into (vector) (range 9999))] (nth nums 5000))
4998
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment