Skip to content

Instantly share code, notes, and snippets.

Last active Aug 10, 2017
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 ()
(let ((items (-repeat 20 'foo)))
"as function (seconds): %s"
(car (benchmark-run 100000 (-first-item-fn items))))
"as alias (seconds): %s"
(car (benchmark-run 100000 (-first-item-alias items))))
"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