Skip to content

Instantly share code, notes, and snippets.

@svetlyak40wt
Forked from xh4/html-test.lisp
Last active March 12, 2020 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svetlyak40wt/38674abdb0e94adfbc575d9b4d11c6bf to your computer and use it in GitHub Desktop.
Save svetlyak40wt/38674abdb0e94adfbc575d9b4d11c6bf to your computer and use it in GitHub Desktop.
Common Lisp HTML Generation Test
(in-package :cl-user)
(ql:quickload :cl-who)
(ql:quickload :spinneret)
(defpackage :html-test
(:use :cl :cl-who :spinneret))
(in-package :html-test)
(defun test-html-cl-who ()
(eval
`(progn
(with-html-output-to-string (string)
,@(loop repeat 1024
collect `(:tr
,@(loop repeat 1024
collect '(:td)))))
nil)))
(defun test-html-spinneret ()
(eval
`(progn
(with-output-to-string (*html*)
(with-html
,@(loop repeat 1024
collect `(:tr
,@(loop repeat 1024
collect '(:td))))))
nil)))
;; Correct spinneret usage is:
(defun test-html-spinneret2 ()
(spinneret:with-html-string
(spinneret:with-html
(loop repeat 1024
do (:tr
(loop repeat 1024
do (:td)))))))
;; It has normal performance:
;;
;; CL-USER> (time (defparameter *result* (test-html-spinneret2)))
;; Evaluation took:
;; 0.378 seconds of real time
;; 0.378023 seconds of total run time (0.368753 user, 0.009270 system)
;; 100.00% CPU
;; 834,907,206 processor cycles
;; 58,117,312 bytes consed
;;
;; *RESULT*
;; CL-USER> (length *result*)
;; 6296576 (23 bits, #x601400)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment