On Jan 29, 2006, at 2:18 PM, Marc Feeley wrote:
Also, you can change the buffering dynamically (and character and end-of-line encoding), from within Scheme, with
(port-settings-set! port settings)
for example
(port-settings-set! (current-output-port) '(buffering: line)) (port-settings-set! (current-output-port) '(char-encoding: utf8 buffering: #t))
This is great. I need to read the header of a pgm image unbuffered; when the rest of the 4MB read was unbuffered, it took
(define g (time (read-pgm "../IMG0001/IMG0001-cropped.pgm")))
(time (read-pgm "../IMG0001/IMG0001-cropped.pgm")) 29139 ms real time 24021 ms cpu time (8039 user, 15982 system) 1 collection accounting for 139 ms real time (77 user, 58 system) 33565368 bytes allocated no minor faults no major faults
When I changed the port setting of the open port to use buffering before reading the binary part of the file, it took
(define g (time (read-pgm "../IMG0001/IMG0001-cropped.pgm")))
(time (read-pgm "../IMG0001/IMG0001-cropped.pgm")) 2093 ms real time 1848 ms cpu time (1769 user, 79 system) no collections 33567464 bytes allocated no minor faults no major faults
Brad