Experiments with posix vs. port I/O added by alaricsp on Mon Jun 24 15:01:58 2013
(use srfi-4) (use miscmacros) (use posix) (define test-data (make-u8vector (* 1024 1024))) (define N 1024) (define t #f) (printf "Dealing with ~A I/Os of ~A bytes each\n" N (u8vector-length test-data)) (printf "write-u8vector:\n") (set! t (current-milliseconds)) (time (with-output-to-file "test.dat" (lambda () (repeat N (write-u8vector test-data))))) (printf "Wall time: ~As\n" (/ (- (current-milliseconds) t) 1000)) (printf "file-write:\n") (set! t (current-milliseconds)) (time (let ((fd (file-open "test2.dat" (+ open/wronly open/creat)))) (repeat N (file-write fd (u8vector->blob/shared test-data))) (file-close fd))) (printf "Wall time: ~As\n" (/ (- (current-milliseconds) t) 1000)) (printf "read-u8vector!:\n") (set! t (current-milliseconds)) (time (with-input-from-file "test.dat" (lambda () (repeat N (read-u8vector! (u8vector-length test-data) test-data))))) (printf "Wall time: ~As\n" (/ (- (current-milliseconds) t) 1000)) (printf "file-read:\n") (set! t (current-milliseconds)) (time (let ((fd (file-open "test2.dat" (+ open/rdonly)))) (repeat N (file-read fd (u8vector-length test-data) (u8vector->blob/shared test-data))) (file-close fd))) (printf "Wall time: ~As\n" (/ (- (current-milliseconds) t) 1000)) Results on my crappy VM: Dealing with 1024 I/Os of 1048576 bytes each write-u8vector: 39.82s CPU time, 0.05s GC time (major), 62 mutations, 37/1179479 GCs (major/minor) Wall time: 44.635s file-write: 3.26s CPU time, 52 mutations, 0/11 GCs (major/minor) Wall time: 14.339s read-u8vector!: 0.46s CPU time, 80 mutations, 0/15 GCs (major/minor) Wall time: 0.509s file-read: 0.37s CPU time, 88 mutations, 0/13 GCs (major/minor) Wall time: 0.38s