#| Testing Unsynchronised hash table, one thread: Finished in 0.14 seconds Testing Boxed hash table, one thread: Finished in 0.20 seconds Testing Boxed hash table, ten threads: Finished in 9.08 seconds Finished in 9.10 seconds Finished in 9.10 seconds Finished in 9.12 seconds Finished in 9.13 seconds Finished in 9.13 seconds Finished in 9.14 seconds Finished in 9.14 seconds Finished in 9.14 seconds Finished in 9.14 seconds Testing Synchronised hash table, one thread: Finished in 0.29 seconds Testing Synchronised hash table, ten threads: Finished in 11.67 seconds Finished in 11.74 seconds Finished in 11.76 seconds Finished in 11.77 seconds Finished in 11.77 seconds Finished in 11.79 seconds Finished in 11.80 seconds Finished in 11.80 seconds Finished in 11.81 seconds Finished in 11.81 seconds Testing Concurrent hash table, one thread: Finished in 0.14 seconds Testing Concurrent hash table, ten threads: Finished in 2.66 seconds Finished in 2.66 seconds Finished in 2.67 seconds Finished in 2.67 seconds Finished in 2.68 seconds Finished in 2.68 seconds Finished in 2.68 seconds Finished in 2.68 seconds Finished in 2.69 seconds Finished in 2.68 seconds |# (defun run-tests () (run-test "Unsynchronised hash table, one thread" 1 (make-hash-table :size 1000000) (incf (gethash key the-table 0))) (run-test "Boxed hash table, one thread" 1 (box (make-hash-table :size 1000000)) (with-unlocked-box (the-table the-table) (incf (gethash key the-table 0)))) (run-test "Boxed hash table, ten threads" 10 (box (make-hash-table :size 1000000)) (with-unlocked-box (the-table the-table) (incf (gethash key the-table 0)))) #+sbcl (progn (run-test "Synchronised hash table, one thread" 1 (make-hash-table :synchronized t :size 1000000) (incf (gethash key the-table 0))) (run-test "Synchronised hash table, ten threads" 10 (make-hash-table :synchronized t :size 1000000) (incf (gethash key the-table 0)))) (run-test "Concurrent hash table, one thread" 1 (make-chash-table :segment-size (round 1000000 +segments+)) (modchash key the-table (lambda (old-value present?) (if present? (values (1+ old-value) t) (values 0 nil))))) (run-test "Concurrent hash table, ten threads" 10 (make-chash-table :segment-size (round 1000000 +segments+)) (modchash key the-table (lambda (old-value present?) (if present? (values (1+ old-value) t) (values 0 t))))))