-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbenchmarks.lisp
37 lines (30 loc) · 1.24 KB
/
benchmarks.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
(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*)
(time
(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
and
sum length into array-length
finally
(preallocate-objects (setf *indexes* (make-array array-length))
info)))