Commit 8c5fe050 authored by Stas Boukarev's avatar Stas Boukarev
Browse files

Add some benchmarks.

parent b763167d
(in-package #:storage)
;;; conses
(defvar *test-file* #p"/tmp/test.db")
(defun save-test (type amount &key object-size)
(let ((object (create-test-object type :object-size object-size)))
(with-io-file (stream *test-file* :direction :output
:size (+ (object-size amount)
(* (object-size object) amount)))
(write-object amount stream)
(loop repeat amount
do (write-object object stream)))))
(defun load-test ()
#+sbcl (sb-ext:gc :full t)
(with-io-file (stream *test-file*)
(loop repeat (read-next-object stream)
do (read-next-object stream)))))
(defgeneric create-test-object (type &key &allow-other-keys))
(defmethod create-test-object ((type (eql 'cons)) &key object-size)
(make-list (or object-size 10000) :initial-element nil))
(defun class-preallocation-test (storage)
(loop for class in (storage-data storage)
for length = (length (objects-of-class class))
when (plusp length)
collect (cons class length) into info
sum length into array-length
(preallocate-objects (setf *indexes* (make-array array-length))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment