Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Sizeof in SBCL

Name: Anonymous 2012-03-09 6:46

Is there a way to get object's size? I want to know, how much memory waste my doubles.

Name: Anonymous 2012-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))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List