In article <rHeu6.12249$TW.48...@tor-nn1.netcom.ca>, "Bruce Roberts"
Quote
<b...@bounceitattcanada.xnet> writes:
><bn...@XXXsympatico.ca> wrote in message
>news:bpiibt8mkil1mk333e5r7r5h8d04671213@4ax.com...
>> I'm trying to replicate my tiny Clipper app that reads a data stream file
>> (no CR or LFs) and writes it out to a text file with hard returns, but
>I've
>> hit a snag.
> <snip some good code from Bruce>
Recently I've been doing some work using wave files and MMIO (MultiMedia I/O)
functions which have an automatically implemented I/O buffer so I thought I
would do a few time comparisons on breaking a 1.7Mb file into 100 character
lines using Bruce's code, similar code using a memory stream, and MMIO
functions.
The results (500Mhz, Win 98SE, 256Mb RAM, 2Mb cache on DMA 66 IBM HD) are as
follows in millisecs with the first figure being directly after a reboot, the
next is an average of a further five copies without a reboot ...
File Stream 1785 mSecs, 1582 mSecs
MemoryStream 512 mSecs, 144 mSecs
MMIO 226 mSecs, 88 mSecs
With just reload of the splitting program, the second figures are obtained
immediately. I guess that the reduction comes from the large HD cache, although
loading some large files in an attempt to flush the cache made little
difference.
Timer was a QP timer, code for mmio as follows ...
uses
MMSystem;
procedure CopyAndBreakMMIO(Src, Dst : string; lineLength : integer);
var
InFile, OutFile : hMMIO;
Buf : string;
begin
InFile := mmioOpen(PChar(Src), nil,
MMIO_READ or MMIO_COMPAT
or MMIO_ALLOCBUF) ;
try
OutFile := mmioOpen(PChar(Dst), nil,
MMIO_WRITE or MMIO_CREATE or MMIO_EXCLUSIVE
or MMIO_ALLOCBUF) ;
try
SetLength (Buf, LineLength + 2);
Buf [LineLength + 1] := #13;
Buf [LineLength + 2] := #10;
mmioSeek(InFile, 0, SEEK_SET);
while (mmioRead(InFile, @Buf[1], LineLength) > 0) do
mmioWrite(OutFile, @Buf[1], LineLength + 2);
finally
mmioClose(OutFile, 0);
end;
finally
mmioClose(InFile, 0);
end;
end;
Alan Lloyd
alangll...@aol.com