--- Mattias Gaertner <[EMAIL PROTECTED]> escribió:
> On Sun, 21 Jan 2007 17:37:20 +0300
> Al Boldi <[EMAIL PROTECTED]> wrote:
>
> > Mattias Gaertner wrote:
> > > Al Boldi <[EMAIL PROTECTED]> wrote:
> > > > Vincent Snijders wrote:
> > > > > Jesus Reyes schreef:
> > > > > > --- Al Boldi <[EMAIL PROTECTED]> escribiظژ:
> > > > > >> TListBox: 10k rows in 73sec
> > > > > >> TTreeView: 100k rows in 50sec
> > > > > >> TMemo: 100k rows in 30sec
> > > > > >> TListView: 100k rows in 1.5sec
> > > > > >> TStringGrid: 100k rows in 0.5sec
> > > > > >
> > > > > > Are you sure?, this doesn't match with Mattias mail.
> > > > >
> > > > > Al, did you set the focused row to the last added rows
> after
> > > > > each 10 rows?
> > > >
> > > > Here is the code:
> > > > ============================
> > > > StringGrid1.RowCount:=100002;
> > > > i:=0;
> > > > repeat
> > > > inc(i);
> > > > StringGrid1.Cells[0,i]:='tst'+inttostr(i);
> > > > until i>100000;
> > > > ============================
> > >
> > > The component is updated several times a second to give the
> user
> > > visual feedback during the compilation progress. At the moment
> > > every read line is either added to the TListBox or replacing
> the
> > > last line of the TListBox. So changing RowCount would be called
> > > every added line. The message window is using Begin/EndUpdate.
> It
> > > calls them about three times a second. So basically there are a
> lot
> > > of 'change last item', many adds and several Begin/EndUpdates.
> > > That's why I tried:
> > >
> > > StringGrid1.ColCount:=1;
> > > StringGrid1.BeginUpdate;
> > > for i:=1 to 100000 do begin
> > > StringGrid1.RowCount:=i;
> >
> > This line basically kills TStringGrid.
>
> Yes, but the IDE does not know the number of lines in advance.
In my opinion, this is not necesary, I don't know nobody that reads
the lines as fast as they are produced, if that was the purpose why
would need to have a dead list anyway.
This only helps to have some visual indication that it's working but
appart from that it's not that useful.
> Of course it would be possible to write a wrapper to add in bigger
> chunks.
>
>
> > TStringGrid gains it's speed from preallocating the list.
> >
> > Preallocating the tree in TTreeView could improve its speed a
> lot.
>
> I doubt that. It already works with exponential growth.
> I still wonder why your treeview times are so much slower than
> mines.
> Did you use Begin/EndUpdate?
>
>
> Mattias
>
About the unknown number of lines, I think that is a problem of
implementation only. If you enable -va and -vt you are expecting to
have a lot of lines, always. This information could be used to do
optimization.
At least for StringGrid the preallocation works. With a modification
of al's code and some tweaking it can be obtained decent results.
StartTimer;
i:=0;
repeat
inc(i);
if i>stringgrid1.RowCount-1 then begin
StringGrid1.RowCount := StringGrid1.RowCount + 1000; {1}
end;
StringGrid1.Cells[0,i] := 'tst'+inttostr(i);
if i mod 100 = 0 then begin {2}
StringGrid1.Row := i;
Application.processmessages;
end;
until i>100000;
StringGrid1.RowCount:=i;
StringGrid1.Row:=i-1;
EndTimer;
There are two points of tweaking here {1} and {2} changing these
increase or decrease performance.
Please don't misunderstand me. I think the treeview it's ok. I only
wanted to show that well, though StringGrid is not too optimized it
is not also that bad.
Jesus Reyes A.
___________________________________________________________
Do You Yahoo!?
La mejor conexión a Internet y <b >2GB</b> extra a tu correo por $100 al mes.
http://net.yahoo.com.mx
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives