Is there a way to get object's size? I want to know, how much memory waste my doubles.
Name:
Anonymous2012-03-09 7:44
(defmacro sizeof (type)
(let* ((n 100000)
(o (with-output-to-string (s)
(let ((*standard-output* s)
(*trace-output* s))
(eval `(time (make-array ,n :element-type ',type))))))
(o (loop for i = 0 then (1+ j)
as j = (position #\Newline o :start i)
collect (subseq o i j)
while j))
(o (caddr (reverse o)))
(o (coerce (remove-if (lambda (x) (char= x #\,)) (coerce o 'list))
'string))
(o (truncate (read-from-string o) n)))
o))