I/O: slow or fast
- Posted by Carlos Valdes <cvaldes at DF.GOB.MX> Mar 03, 1999
- 374 views
I saw the program on i/o posted before and I changed the read routine including a preassembled sequence in memory, just to test. See the difference! constant NONE = -1 -- one of three booleans global function read_textfile (sequence fname) sequence s integer char, fh fh = open (fname, "r") if fh = NONE then return "" end if s = "" char = getc (fh) while char != NONE do s = append(s, char) end while return s end function global function read_text_preseq(sequence fname) object s atom char, fh, c c=1 fh = open (fname, "r") if fh = NONE then return "" end if s =repeat(0,200000) char = getc (fh) while char != NONE do s[c] = char char = getc (fh) c=c+1 end while return s end function object ya atom t t=time() ?t ya=read_text_preseq("win32lib.ew") ?time()-t t=time() ya=read_textfile("win32lib.ew") ?time()-t --?ya