Re: J. French - See this ?



On Tue, 30 Aug 2005 09:35:29 -0500, "Richard" <REMOVE
AT-DOTrwskinnerAT@awesomenetDOTnet> wrote:

>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');

Yes, I can see what is happening

This is not exactly a valid test, you are comparing the behaviour of a
TStringStream and a TStringList

Now try adding the data directly to the TAbZipper without building an
intermediary Stream
- you may find it slower
- that depends on TAbZipper
it might prefer to get its data from a Stream - it might not

The real question is :
'is it necessary to push data into TAbZipper from Streams ?'


.


Quantcast