File I/O Metrics

Pascal Bourguignon pjb at informatimago.com
Fri Oct 21 21:50:01 UTC 2022


Le 21/10/2022 à 23:18, Garrett Dangerfield a écrit :
> I tried changing (make-array buffer-size :element-type 'character)
> to
> (make-array buffer-size :element-type 'byte)
> and I got additional warnings and it took 70 seconds instead of 20.
> 

You need to specify a binary file too!

(deftype octet () '(unsigned-byte 8))
(with-open-file (stream #P"~/Downloads/Discord.dmg"
                         :element-type 'octet
                         :external-format :default)
   (print `(size = ,(file-length stream)))
   (let ((buffer-size (* 16 1024 1024)))
     (time
      (loop with buffer = (make-array buffer-size :element-type 'octet)
            for n-bytes = (read-sequence buffer stream)
            while (plusp n-bytes)))))



-- 
__Pascal Bourguignon__




More information about the armedbear-devel mailing list