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 time before and after N iterations of a loop."
(let ((t1 (current-time-string)))
(while (> (setq n (1- n))
0))
(list t1 (current-time-string))))
⇒ silly-loop
(silly-loop 50000000)
⇒ ("Wed Mar 11 21:10:19 2009"
"Wed Mar 11 21:10:41 2009") ; 22 seconds
(byte-compile 'silly-loop)
⇒ [Compiled code not shown]
(silly-loop 50000000)
⇒ ("Wed Mar 11 21:12:26 2009"
"Wed Mar 11 21:12:32 2009") ; 6 seconds
In this example, the interpreted code required 22 seconds to run, whereas the byte-compiled code required 6 seconds. These results are representative, but actual results will vary greatly.
blog comments powered by Disqus