Skip to content

Instantly share code, notes, and snippets.

@borkdude
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borkdude/33d79402e689460e62d6 to your computer and use it in GitHub Desktop.
Save borkdude/33d79402e689460e62d6 to your computer and use it in GitHub Desktop.
user> (def my-transducer (comp (filter odd?) (filter odd?) (filter odd?)))
#'user/my-transducer
user> (def my-func (comp #(filter odd? %) #(filter odd? %) #(filter odd? %)))
#'user/my-func
user> (time (dotimes [x 10000] (doall (my-func (range 1000)))))
"Elapsed time: 2684.170568 msecs"
nil
user> (time (dotimes [x 10000] (doall (my-func (range 1000)))))
"Elapsed time: 2477.983258 msecs"
nil
user> (time (dotimes [x 10000] (doall (sequence my-transducer (range 1000)))))
"Elapsed time: 3110.309093 msecs"
nil
user> (time (dotimes [x 10000] (doall (sequence my-transducer (range 1000)))))
"Elapsed time: 3129.188543 msecs"
nil
user> (time (dotimes [x 10000] (into [] my-transducer (range 1000))))
"Elapsed time: 2153.223321 msecs"
nil
user> (time (dotimes [x 10000] (into [] my-transducer (range 1000))))
"Elapsed time: 2113.313468 msecs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment