Last active
August 10, 2017 08:45
-
-
Save Wilfred/3ee025116cff82169435262f44bffb0c to your computer and use it in GitHub Desktop.
function calls vs aliases
This file contains hidden or 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
;;; 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