Created
February 20, 2020 10:53
-
-
Save runejuhl/339e886b05a5d970379c846f2678fe11 to your computer and use it in GitHub Desktop.
Simple function benchmark comparison
This file contains 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
(defn time* | |
[fs iterations] | |
(map-indexed | |
(fn [idx f] | |
(let [t (with-out-str | |
(time | |
(run! f (range iterations))))] | |
{:idx idx | |
:f f | |
:time t})) | |
fs)) | |
(time* [(fn [_] | |
(merge-with into | |
{:omg {:lol 12 | |
:wat {:wooo 12}}})) | |
(fn [_] | |
(merge-with merge | |
{:omg {:lol 12 | |
:wat {:wooo 12}}}))] 1e7) | |
;; => ({:idx 0, | |
;; :f #function[dev/eval76792/fn--76793], | |
;; :time "\"Elapsed time: 1751.630289 msecs\"\n"} | |
;; {:idx 1, | |
;; :f #function[dev/eval76792/fn--76795], | |
;; :time "\"Elapsed time: 1173.778828 msecs\"\n"}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment