From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/elisp/speed-of-byte_002dcode.html | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 devdocs/elisp/speed-of-byte_002dcode.html (limited to 'devdocs/elisp/speed-of-byte_002dcode.html') diff --git a/devdocs/elisp/speed-of-byte_002dcode.html b/devdocs/elisp/speed-of-byte_002dcode.html new file mode 100644 index 00000000..dae47485 --- /dev/null +++ b/devdocs/elisp/speed-of-byte_002dcode.html @@ -0,0 +1,25 @@ +

Performance of Byte-Compiled Code

A byte-compiled function is not as efficient as a primitive function written in C, but runs much faster than the version written in Lisp. Here is an example:

(defun silly-loop (n)
+  "Return the time, in seconds, to run N iterations of a loop."
+  (let ((t1 (float-time)))
+    (while (> (setq n (1- n)) 0))
+    (- (float-time) t1)))
+⇒ silly-loop
+
+ +
(silly-loop 50000000)
+⇒ 10.235304117202759
+
+ +
(byte-compile 'silly-loop)
+⇒ [Compiled code not shown]
+
+ +
(silly-loop 50000000)
+⇒ 3.705854892730713
+
+

In this example, the interpreted code required 10 seconds to run, whereas the byte-compiled code required less than 4 seconds. These results are representative, but actual results may vary.

+

+ Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc.
Licensed under the GNU GPL license.
+ https://www.gnu.org/software/emacs/manual/html_node/elisp/Speed-of-Byte_002dCode.html +

+
-- cgit v1.2.3