Mattias Gaertner wrote:
> Al Boldi <[EMAIL PROTECTED]> wrote:
> > > > > >> 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
> > > >
> > > > Here is the code:
> > > > ============================
> > > >   StringGrid1.RowCount:=100002;
> > > >   i:=0;
> > > >   repeat
> > > >     inc(i);
> > > >     StringGrid1.Cells[0,i]:='tst'+inttostr(i);
> > > >   until i>100000;
> > > > ============================
> > >
> > > 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.
> 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.

Preallocate in 16sec ============
  TreeView1.BeginUpdate;
  TreeView1.Items.Clear;
  for i:=1 to 100000 do
    TreeView1.Items.Add(nil,'');
  TreeView1.EndUpdate;
=================================

Fill tree in 2sec ===============
  TreeView1.BeginUpdate;
  for i:=1 to 100000 do begin
    TreeView1.Items[i-1].Text:='tst'+IntToStr(i);
    for j:=1 to 10 do
      TreeView1.Items[i-1].Text:=IntToStr(i)+','+IntToStr(j);
  end;
  TreeView1.EndUpdate;
=================================

> I still wonder why your treeview times are so much slower than mines.
> Did you use Begin/EndUpdate?

No preallocation > 2min ^C ======
  TreeView1.BeginUpdate;
  TreeView1.Items.Clear;
  for i:=1 to 100000 do begin
    TreeView1.Items.Add(nil,'tst'+inttostr(i));
    for j:=1 to 10 do
      TreeView1.Items[i-1].Text:=IntToStr(i)+','+IntToStr(j);
  end;
  TreeView1.EndUpdate;
=================================


Thanks!

--
Al

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to