(in-package :cl-user) (defun ht-gen () (loop repeat 100000 collect (let ((h (make-hash-table :test #'equal))) (setf (gethash (copy-seq "foo") h) 10 (gethash (copy-seq "bar") h) 20) h))) (defun ht-bench () (gc) (terpri) (write-line ";;;; ---- Constructing hash table ----") (let ((hts (time (ht-gen)))) (terpri) (write-line ";;;; ---- Accessing hash table ----") (time (loop for ht in hts sum (+ (gethash "foo" ht) (gethash "bar" ht)))))) (defun pl-gen () (loop repeat 100000 collect (list :foo 10 :bar 20))) (defun pl-bench () (gc) (terpri) (write-line ";;;; ---- Constructing PLIST ----") (let ((pls (time (pl-gen)))) (terpri) (write-line ";;;; Accessing PLIST") (time (loop for pl in pls sum (destructuring-bind (&key foo bar) pl (+ foo bar)))))) (print (list (lisp-implementation-type) (lisp-implementation-version))) (terpri) (print (ht-bench)) (print (pl-bench)) (terpri)