Re: J. French - See this ?



Check this out, going building the Array to a Strinlist, then saving to a
stream, then compressing to Disk this route is WAY faster then adding the
Array directly to a stringStream.

This entire deal takes a tad over 2 seconds, from start to end. Going
directly to a StringStream with the same array was taking minutes.

procedure TForm1.Button1Click(Sender: TObject);
Var str : TStringStream;
sList : TStringList;
x, Y : Integer;
s : String;
aZip : tAbZipper;
aryStartTime, aryEndTime : TDateTime;
listStartTime, listEndTime : TDateTime;
strmStartTime, strmEndTime : TDateTime;
zipStartTime, zipEndTime : TDateTime;
totStartTime, totEndTime : TDateTime;



begin
Memo1.Clear;
totStartTime := now;
Str := tStringStream.Create(s);
sList := TStringList.Create;

ProgressBar1.Min := 1;
ProgressBar1.Max := 43200;
ProgressBar1.StepBy(500);

aryStartTime := now;
For x := 1 to 43200 do
Begin
s := '';
For Y := 1 to 60 do
Begin
If Y < 60 then
s := s + IntToStr(y)+ ',' Else
s := s + IntToStr(y);
End;
slist.Add(s);
ProgressBar1.Position := x;
Application.ProcessMessages;
End;
aryEndTime := Now;

strmStartTime := Now;
sList.SaveToStream(Str);
strmEndTime := Now;
sList.Free;

zipStartTime := Now;
aZip := TAbZipper.Create(nil);
azip.FileName := 'd:\Test.Zip';
azip.AddFromStream('d:\test.csv', Str);
azip.Save;
azip.CloseArchive;
azip.Free;
Str.Free;
zipEndTime := Now;
totEndTime := Now;

Memo1.Lines.Add('Array Build Time : ' +
IntToStr(MilliSecondsBetween(AryStartTime,AryEndTime)) + ' mSeconds');
Memo1.Lines.Add('Stream Build Time : ' +
IntToStr(MilliSecondsBetween(StrmStartTime,StrmEndTime)) + ' mSeconds');
Memo1.Lines.Add('Zip Build Time : ' +
IntToStr(MilliSecondsBetween(zipStartTime,zipEndTime)) + ' mSeconds');
Memo1.Lines.Add('---------------------------------------------');
Memo1.Lines.Add('Total Procedure Time : ' +
IntToStr(MilliSecondsBetween(totStartTime,totEndTime)) + ' mSeconds');


end;



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
.


Quantcast