Skip to content

Instantly share code, notes, and snippets.

@Wilfred
Last active August 10, 2017 08:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wilfred/3ee025116cff82169435262f44bffb0c to your computer and use it in GitHub Desktop.
Save Wilfred/3ee025116cff82169435262f44bffb0c to your computer and use it in GitHub Desktop.
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