Re: File I/O Metrics
Pascal Bourguignon <[email protected]> Fri, 21 Oct 2022 23:50:01 +0200
| Newsgroups | gmane.editors.j.devel |
|---|---|
| Message-ID | <[email protected]> |
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__