Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defparameter *test* (cons 0 0))
- (defun make-random-keys (n)
- (let ((keys (loop :repeat n
- :collect (u:kintern (gensym)))))
- keys))
- (defun popht (keys)
- (let ((ht (make-hash-table :size (length keys))))
- (loop :for key :across keys
- :for i :from 0
- :do (setf (gethash key ht) i))
- ht))
- (defun test (n &optional (times 1000))
- (let* ((list (make-random-keys n))
- (array (apply #'vector list))
- (ht (popht array))
- (random-list (u:randomize list)))
- (u:time-nogc (rplaca *test* (loop :repeat times
- :collect (loop :for key :in random-list
- :collect (gethash key ht)))))
- (u:time-nogc (rplacd *test* (loop :repeat times
- :collect (loop :for key :in random-list
- :collect (position key array)))))
- (values)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement