Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-11

StringGrid performance problems

15 messages · 9 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Op 2010-11-16 18:14, Lee Jenkins het geskryf:

applications, but against my judgment I figured I'd give lazarus another go for a GUI app which was a mistake apparently.

Following up from Lee's post, but related to StringGrids. I too tried to used LCL again, for a External Tracing/Debugging tool. My plans was to make an executable for fpGUI and LCL. The latter giving users the native look and feel and all that... I use StringGrid components a lot in my fpGUI apps, so that was my first choice for the display component, but for some reason I couldn't use it under the LCL version of my tool.

What does my app do. It works something like the "debug server" included with Lazarus, but a lot more detailed with what it displays and how the developer can manipulate the traced data. Log information comes in hard and fast, and unlimited in volume - depending on what you are debugging of course, and the amount of traces/logs you setup.

I then did a simple test to see what could be the cause of problems in the LCL app (and why it looks frozen). I created a stringgrid with exact dimensions, a single column. I then used a simple test method that generates log entries (8 million to be exact - did start small though). Each time a log is received, I do a BeginUpdate, add a new row to the grid, populate the first cell with a number, then call EndUpdate. Under fpGUI this test took 5 seconds to complete, MSEgui took 10 seconds (just for fun, I tied MSEgui too). LCL took.... well, I kill the app after 3 hours of 100% CPU load and still nothing being displayed. Thank goodness I have a quad core, so the 100% load on one core did not affect my day-to-day work.

Anybody know about the performance problems in TStringGrid? Anybody tracked down what exactly is causing its bad performance? I can only assume the problem is known, and the reason why Lazarus IDE itself uses a TreeView instead of a StringGrid for the Messages window.

Should I report this in Mantis?

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net:8080/fpgui/

Reply by email

Martin Schreiber
to Graeme Geldenhuys
Graeme Geldenhuys wrote 11 lines
I then did a simple test to see what could be the cause of problems in the LCL app (and why it looks frozen). I created a stringgrid with exact dimensions, a single column. I then used a simple test method that generates log entries (8 million to be exact - did start small though). Each time a log is received, I do a BeginUpdate, add a new row to the grid, populate the first cell with a number, then call EndUpdate. Under fpGUI this test took 5 seconds to complete, MSEgui took 10 seconds (just for fun, I tied MSEgui too). LCL took.... well, I kill the app after 3 hours of 100% CPU load and still nothing being displayed. Thank goodness I have a quad core, so the 100% load on one core did not affect my day-to-day work.

You probably should give a little bit more information. ;-) The thread is here:
http://msegui.org/fudforum/index.php?t=msg&th=20921&goto=136104&rid=0&S=c3696d6681449225b1fe14c93101f120#msg_136104

My results with MSEgui:
"
I get the following results with AMD Athlon XP3000+, 1GB RAM: (2GB in mail was wrong information)

1: Your testcase: 33.9s (this is the equivalent of your 10 seconds on my slower computer)
[...]
2. Assigning a UnicodeString (no iconv calls): 16.9s [...]
3. No column index in loop: 16.3s
[...]
4: Direct access to the column datalist: 3.54s
[...]
5: Direct access to the data with allocating the memory once: 0.52s [...]
With Unicode inttostr() I get 6.3s (trunk 4061):
[...]
"

Martin

Reply by email

Jesus Reyes
to Graeme Geldenhuys: Op 2010-11-16 18:14, Lee Jenkins het geskryf: Following up from Lee's post, but related…

--- El mi? 17-nov-10, Graeme Geldenhuys escribi?:

Show quoted text 18 lines
Under fpGUI this test took 5 seconds to complete, MSEgui took 10 seconds (just for fun, I tied MSEgui too). LCL took.... well, I kill the app after 3 hours of 100% CPU load and still nothing being displayed. Thank goodness I have a quad core, so the 100% load on one core did not affect my day-to-day work. Anybody know about the performance problems in TStringGrid? Anybody tracked down what exactly is causing its bad performance?? I can only assume the problem is known, and the reason why Lazarus IDE itself uses a TreeView instead of a StringGrid for the Messages window.

I remember some test were made and the grid was winner \o/, on why the stringgrid was not selected for this task, doesn't matter here, everybody is happy that I know.

Should I report this in Mantis?

Sure, I think it can be improved but currently I have other priorities.

Using the link martin provided I tried to create a sample to test myself and yes, it's extremely slow. I timed about 127 seconds only for 50000 rows :) a powerful ctrl+break ended with it's misery.

I was trying to find documentation about fpGUI stringgrid features but I couldn't find it, I tried looking at the code in sf site, it seems fpGUI stringgrid has a limited set of features compared to lazarus (or delphi) stringgrid, for example I didn't see in the code how you can set variable row height, or fixed cols/rows.

Just for fun and because columns seems to support variable width, can you do the same test but instead of rows use cols?, I mean instead of rowcount:=x do colcount := x and do cell[i, 0] := xstr

Jesus Reyes A.

Reply by email

Graeme Geldenhuys
to Jesus Reyes

Op 2010-11-18 00:19, Jesus Reyes het geskryf:

Sure, I think it can be improved but currently I have other priorities.

Understood, I just wanted to know if it was a known problems. For the LCL version of my app, I'll try the ListView (or TreeView like Lazarus IDE does).

I was trying to find documentation about fpGUI stringgrid

There is none for the grids. I'm almost done with the corelib class documentation, then I'll start on the GUI components. Writing decent documentation takes longer than I expected. Now I fully respect the effort Michael put in to write the RTL and FCL docs.

couldn't find it, I tried looking at the code in sf site, it seems fpGUI stringgrid has a limited set of features compared to lazarus (or delphi) stringgrid, for example I didn't see in the code how you can set variable row height, or fixed cols/rows.

Row height can be set via DefaultRowHeight property. I have not found a use for variable height rows (one row taller than another), but it is easy to add if the need arises (all the infrastructure code is there). Even in the 8 year of working with Delphi, I've never used that either. If content doesn't fit, use a tooltip - that's the normal behaviour users expect.

Fixed rows are handled differently in fpGUI. Fixed rows are not part of the rowcount in fpGUI. They are separated out, and have their own dedicated properties to adjust the header style, content, width etc.

Fixed columns are treated simply as normal grid column, but by disabling keyboard or mouse focus in them. The look can be adjusted by the developer to suite their needs (flat, medium, button, greyed, any color or look etc). This also allows "fixed columns" to appear anywhere in the grid, not just on the left edge.

Just for fun and because columns seems to support variable width, can you do the same test but instead of rows use cols?, I mean instead of rowcount:=x do colcount := x and do cell[i, 0] := xstr

7 seconds for 8 million columns. See attached screenshots.

----------[ the code ]----------------------
procedure TMainForm.ButtonClicked(Sender: TObject);
var
 i: integer;
begin
  et.Clear;
  et.Start;
  Grid1.BeginUpdate;
  for i := 1 to 8000000 do
  begin
    Grid1.ColumnCount := i;
    Grid1.Cells[i-1,0] := InttoStr(i);
  end;
  Grid1.EndUpdate;
  lblTime.Text := et.ElapsedDHMS;
end;
------------------[ end ]-------------------

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net:8080/fpgui/ -------------- next part -------------- A non-text attachment was scrubbed... Name: MainForm_001.png Type: image/png Size: 3604 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20101118/274f7858/attachment-0002.png> -------------- next part -------------- A non-text attachment was scrubbed... Name: MainForm_002.png Type: image/png Size: 3519 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20101118/274f7858/attachment-0003.png>

Reply by email

Unknown author
to Graeme Geldenhuys
Graeme Geldenhuys wrote 14 lines
Op 2010-11-18 00:19, Jesus Reyes het geskryf: > > Sure, I think it can be improved but currently I have other priorities. Understood, I just wanted to know if it was a known problems. For the LCL version of my app, I'll try the ListView (or TreeView like Lazarus IDE does). > I was trying to find documentation about fpGUI stringgrid There is none for the grids. I'm almost done with the corelib class documentation, then I'll start on the GUI components. Writing decent documentation takes longer than I expected. Now I fully respect the effort Michael put in to write the RTL and FCL docs.

Recognition, at last... :)

Michael.

Reply by email

Unknown author
to Graeme Geldenhuys: Op 2010-11-18 10:51, michael.vancanneyt at xxxx het geskryf: :-) Indeed, you did an…
Graeme Geldenhuys wrote 8 lines
Op 2010-11-18 10:51, michael.vancanneyt at xxxx het geskryf: >> documentation takes longer than I expected. Now I fully respect the effort >> Michael put in to write the RTL and FCL docs. > > Recognition, at last... :) :-) Indeed, you did an amazing job.

Well, it's an ongoing effort, to say the least.

Michael.

Reply by email

Marc Weustink
to Graeme Geldenhuys: Op 2010-11-18 00:19, Jesus Reyes het geskryf: Understood, I just wanted to know if it was…
Graeme Geldenhuys wrote 6 lines
Op 2010-11-18 00:19, Jesus Reyes het geskryf: > > Sure, I think it can be improved but currently I have other priorities. Understood, I just wanted to know if it was a known problems. For the LCL version of my app, I'll try the ListView (or TreeView like Lazarus IDE does).

On windows, the native Listview is slow, the native treeview even slower.

If possible I would suggest using a VirtualTree when you want to add more than 1000 rows.

Marc

Reply by email

zeljko
to Graeme Geldenhuys: Op 2010-11-18 00:19, Jesus Reyes het geskryf: Understood, I just wanted to know if it was…
Graeme Geldenhuys wrote
Fixed rows are handled differently in fpGUI. Fixed rows are not part of the rowcount in fpGUI. They are separated out, and have their own dedicated properties to adjust the header style, content, width etc.
So your rowCount doesn't take into account headers and Cells[0,1] := 'MyText'
doesn't change header cell text but real cell ?

zeljko

Reply by email

Graeme Geldenhuys
to zeljko

Op 2010-11-18 12:57, zeljko het geskryf:

So your rowCount doesn't take into account headers and Cells[0,1] := 'MyText' doesn't change header cell text but real cell ?

Correct. Headers are just that, headers (or also known as Columns). Rows are just that, rows. The concept seems quite logical to me, and I believe it is similar to what LCL or VCL's ListView does too. In a LCL/VCL TListview (with Style = vsReport), the Items can be 0, but you still see column headers. They are handled / setup separately to the data (items or rows in the control). So why must grids be different.

  Grid1.ColumnTitle[0] := 'test';
  Grid1.ColumnWidth[0] := 80;
or
  Grid1.Columns[0].Title := 'test';
  Grid1.Columns[0].Width := 80;

...want to hide the headers...

  Grid1.ShowHeaders := False;

...want a empty grid (meaning no rows, but obviously still with headers)

  Grid1.RowCount := 0;

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net:8080/fpgui/

Reply by email

Alexsander Rosa
to Marc Weustink: On windows, the native Listview is slow, the native treeview even slower. If possible I…

I've noticed that (native Listview is slow in Windows) the hard way: I was proud about how fast my app were on Linux then ran it on Windows and the hourglass became the leading actor. Any suggestions for replacement of Listview?

2010/11/18 Marc Weustink

Show quoted text 21 lines
Graeme Geldenhuys wrote: > Op 2010-11-18 00:19, Jesus Reyes het geskryf: > >> >> Sure, I think it can be improved but currently I have other priorities. >> > > Understood, I just wanted to know if it was a known problems. For the LCL > version of my app, I'll try the ListView (or TreeView like Lazarus IDE > does). > On windows, the native Listview is slow, the native treeview even slower. If possible I would suggest using a VirtualTree when you want to add more than 1000 rows. Marc
Atenciosamente, Alexsander da Rosa http://rednaxel.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110520/e7b318ba/attachment.html>

Reply by email

Lee Jenkins
to Alexsander Rosa
Alexsander Rosa wrote 7 lines
I've noticed that (native Listview is slow in Windows) the hard way: I was proud about how fast my app were on Linux then ran it on Windows and the hourglass became the leading actor. Any suggestions for replacement of Listview? 2010/11/18 Marc Weustink < <mailto:>>

I had the same problem actually, but I wanted to ask: Are you on Vista or Win7? I re-wrote the same app with Delphi and the performance, went up but I still see much flicker when cursor is floating over the list view. I did not see this on XP.

Warm Regards, Lee

Reply by email

Alexsander Rosa
to Lee Jenkins

Tested on Windows XP.

2011/5/20 Lee Jenkins

Show quoted text 23 lines
On 5/20/2011 10:24 AM, Alexsander Rosa wrote: > I've noticed that (native Listview is slow in Windows) the hard way: I was > proud > about how fast my app were on Linux then ran it on Windows and the > hourglass > became the leading actor. Any suggestions for replacement of Listview? > > 2010/11/18 Marc Weustink < > <mailto:>> > > I had the same problem actually, but I wanted to ask: Are you on Vista or Win7? I re-wrote the same app with Delphi and the performance, went up but I still see much flicker when cursor is floating over the list view. I did not see this on XP. -- Warm Regards, Lee
Atenciosamente, Alexsander da Rosa http://rednaxel.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110520/721c7449/attachment.html>

Reply by email

Julio César Gázquez
to Alexsander Rosa: I've noticed that (native Listview is slow in Windows) the hard way: I was proud about…

El 20/05/11 11:24, Alexsander Rosa escribi?:

I've noticed that (native Listview is slow in Windows) the hard way: I was proud about how fast my app were on Linux then ran it on Windows and the hourglass became the leading actor. Any suggestions for replacement of Listview?

Native means the win32 native widget? Did you try recompiling with Qt4? AFAIK Qt use their own widgets, so maybe you could get better performance.

/Ing. Julio C?sar G?zquez / MEBA - Mutual de Empleados del Banco/ / Mitre 923 1? Piso 0341- 4110533 / 4265010 / 0800 9990452 S2000COS ROSARIO// / *16 resmas = 1 ?rbol* Raz?n suficiente para pensar si es necesario imprimir este correo -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110520/f543c6ac/attachment.html>

Reply by email

zeljko
to Julio César Gázquez
Julio C?sar G?zquez wrote 8 lines
El 20/05/11 11:24, Alexsander Rosa escribi?: > I've noticed that (native Listview is slow in Windows) the hard way: I > was proud about how fast my app were on Linux then ran it on Windows > and the hourglass became the leading actor. Any suggestions for > replacement of Listview? Native means the win32 native widget? Did you try recompiling with Qt4? AFAIK Qt use their own widgets, so maybe you could get better performance.

Qt's QListWidget/QTreeWidget (TListView) performance isn't so nice. With few thousand items it becomes slow.
Better use TVirtualStringTree , it's ultra fast even when you allocate 1000000 items.

zeljko

Reply by email