example.el 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. (defun html-page (title &rest contents)
  2. (concat "<HTML>\n"
  3. "<HEAD>\n"
  4. "<TITLE>" title "</TITLE>\n"
  5. "</HEAD>\n"
  6. "<BODY>\n"
  7. (apply 'concat contents)
  8. "</BODY>\n"
  9. "</HTML>\n"))
  10. (defmacro time (repeat-count &rest body)
  11. `(let ((count ,repeat-count)
  12. (beg (current-time))
  13. end)
  14. (while (> count 0)
  15. (setq count (- count 1))
  16. ,@body)
  17. (setq end (current-time))
  18. (+ (* 1000000.0 (+ (* 65536.0 (- (car end) (car beg)))
  19. (- (cadr end) (cadr beg))))
  20. (* 1.0 (- (caddr end) (caddr beg))))))
  21. ;Non-scientific performance measurements (Guile measurements are with
  22. ;`guile -q --no-debug'):
  23. ;
  24. ;(time 100000 (+ 3 4))
  25. ; => 225,071 (Emacs) 4,000,000 (Guile)
  26. ;(time 100000 (lambda () 1))
  27. ; => 2,410,456 (Emacs) 4,000,000 (Guile)
  28. ;(time 100000 (apply 'concat (mapcar (lambda (s) (concat s "." s)) '("a" "b" "c" "d"))))
  29. ; => 10,185,792 (Emacs) 136,000,000 (Guile)
  30. ;(defun sc (s) (concat s "." s))
  31. ;(time 100000 (apply 'concat (mapcar 'sc '("a" "b" "c" "d"))))
  32. ; => 7,870,055 (Emacs) 26,700,000 (Guile)
  33. ;
  34. ;Sadly, it looks like the translator's performance sucks quite badly
  35. ;when compared with Emacs. But the translator is still very new, so
  36. ;there's probably plenty of room of improvement.