_SPEEDY BUFFERING_ by Bruce Tonkin [LISTING ONE] DEFINT A-Z CLS LINE INPUT "Name of file to read: "; filename$ INPUT "Record length: "; rl buffersize = (1 + 16384 \ rl) * rl '16K, rounded up. blocks = buffersize \ rl DIM chunk$(1 TO blocks) 'each chunk will be one record. 'open the random file with a record length of buffersize OPEN "r", 1, filename$, buffersize filesize& = CLNG(LOF(1)) \ rl 'set up the buffer in record-length sized chunks FOR i = 1 TO blocks FIELD #1, dummy AS dummy$, rl AS chunk$(i) dummy = dummy + rl NEXT i 'open up a dummy buffer to hold the actual records OPEN "r", 2, "real.$$$", rl FIELD #2, rl AS all$ t1! = TIMER FOR i = 1 TO filesize& GOSUB getrec 'read the buffered records NEXT i t1! = TIMER - t1! 'save the time taken CLOSE 'close the files and delete the dummy file. KILL "real.$$$" OPEN "r", 1, filename$, rl 'now open and read unbuffered FIELD #1, rl AS all$ t2! = TIMER FOR i = 1 TO filesize& GET 1, i NEXT i t2! = TIMER - t2! CLOSE PRINT "Buffered time: "; t1! PRINT "Unbuffered time: "; t2! END getrec: whichblock = 1 + (i - 1) \ blocks IF whichblock <> lastblock THEN GET 1, whichblock lastblock = whichblock end if whichchunk = 1 + i MOD blocks LSET all$ = chunk$(whichchunk) RETURN