Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
function calls vs aliases
;;; dashtest2.el --- benchmarking dash -*- lexical-binding: t -*-
(defun -first-item-fn (lst)
(car lst))
(defalias '-first-item-alias 'car)
(defun wh/benchmark ()
(interactive)
(let ((items (-repeat 20 'foo)))
(message
"as function (seconds): %s"
(car (benchmark-run 100000 (-first-item-fn items))))
(message
"as alias (seconds): %s"
(car (benchmark-run 100000 (-first-item-alias items))))
(message
"car (seconds): %s"
(car (benchmark-run 100000 (car items))))))
;; as function (seconds): 0.13999088499999998
;; as alias (seconds): 0.005465521999999999
;; car (seconds): 0.005004648999999998
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment