Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » GridCtrl performance
GridCtrl performance [message #39737] Mon, 22 April 2013 16:36 Go to next message
crydev is currently offline  crydev
Messages: 151
Registered: October 2012
Location: Netherlands
Experienced Member
Hello,

I am working on a memory scanner project. I use a GridCtrl to visualize the results from a scan to the user. However, I notice that the ArrayCtrl, as well as the GridCtrl are very slow when it comes to adding ~300.000+ items at once. I have 8 threads scanning the memory so the scan is done very fast. The adding and removing of the items from the list however, is slow.

Is there a way to make it faster? Why is it so slow?

Thanks,

Crydev
Re: GridCtrl performance [message #39742 is a reply to message #39737] Mon, 22 April 2013 21:43 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 284
Registered: October 2008
Location: France
Experienced Member
Hello Crydev,

Did you try SetVirtualCount method in ArrayCtrl ?

Regards

Biobytes
Re: GridCtrl performance [message #39743 is a reply to message #39742] Mon, 22 April 2013 22:25 Go to previous messageGo to next message
crydev is currently offline  crydev
Messages: 151
Registered: October 2012
Location: Netherlands
Experienced Member
BioBytes wrote on Mon, 22 April 2013 21:43

Hello Crydev,

Did you try SetVirtualCount method in ArrayCtrl ?

Regards

Biobytes


Yes I tried using it but unfortunately it didn't solve my problem. If I could safely use the multithreaded structure to fill up my GridCtrl it would speed up very much but because it is GUI it isn't possible.
Re: GridCtrl performance [message #39744 is a reply to message #39743] Mon, 22 April 2013 22:50 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1354
Registered: November 2005
Location: Poland
Senior Contributor

GridCtrl uses Vector<Vector<Item>> internally. So inserting is as fast as Vector implementation is. You should observe dramatic speed improvement if you compile your app in release mode (but I assume you did Smile ). If you insert many rows at once you can put insertion part between grid.Ready(false) and grid.Ready(true).
You can also add 300.000 empty rows to the grid in the beginning and simply clear and set particular cells. This way you would avoid removing and inserting rows over and over again.
ArrayCtrl and virtual rows should solve your problem. It seems like you did something wrong, but without the real code it's hard to tell.
Re: GridCtrl performance [message #39770 is a reply to message #39744] Thu, 25 April 2013 11:15 Go to previous messageGo to next message
crydev is currently offline  crydev
Messages: 151
Registered: October 2012
Location: Netherlands
Experienced Member
I see. I tried doing the posted things but no luck, unfortunately.

Is there a more skinned or lightweight list-like control that I can use for this? I'm not sure about how I can customize a control in a way that it will act faster in my situation.

Another question that pops up to me: Is it possible to link the values displayed in the Array/GridCtrl as pointers to the original data? I think I am saving a lot of data redundantly, which is not nessecary ofcourse. Smile
Re: GridCtrl performance [message #39774 is a reply to message #39743] Thu, 25 April 2013 16:47 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 288
Registered: November 2008
Experienced Member
Hello.
crydev wrote on Mon, 22 April 2013 22:25

BioBytes wrote on Mon, 22 April 2013 21:43

Hello Crydev,

Did you try SetVirtualCount method in ArrayCtrl ?

Regards

Biobytes


Yes I tried using it but unfortunately it didn't solve my problem. If I could safely use the multithreaded structure to fill up my GridCtrl it would speed up very much but because it is GUI it isn't possible.

I don't know how you tried it, but try again.

Below is additional example of VirtualArray reference application:
Toggle Spoiler

index.php?t=getfile&id=4152&private=0


Where instead of Vector<String> you could use your "faster" container, filled by parallel, if you want. Or even try to show real time (or cached) results, calculated by some index, without using any container.

[Updated on: Thu, 25 April 2013 17:14]

Report message to a moderator

Re: GridCtrl performance [message #39775 is a reply to message #39774] Thu, 25 April 2013 17:49 Go to previous messageGo to next message
crydev is currently offline  crydev
Messages: 151
Registered: October 2012
Location: Netherlands
Experienced Member
Thanks a lot Sender Ghost, you cleared it up for me, I see how it works. However, I'm having trouble implementing my own data in it. Say I have the following data, how could this be properly implemented using the virtual ArrayCtrl?

<template class T>
struct MemData
{
     int address; // column address
     T value;     // column value
};


Thanks in advance!

Crydev
Re: GridCtrl performance [message #39776 is a reply to message #39775] Thu, 25 April 2013 18:53 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 288
Registered: November 2008
Experienced Member
crydev wrote on Thu, 25 April 2013 17:49

However, I'm having trouble implementing my own data in it. Say I have the following data, how could this be properly implemented using the virtual ArrayCtrl?

template <class T>
struct MemData
{
	int address;	// column address
	T value;	// column value
};



Depends from the type of T. If T is String, then modified version of example application might look like follows:
Toggle Spoiler

If you need to use another types, then just change the function declaration of NumberToText template, but return compatible types for ArrayCtrl values (which is Value).

[Updated on: Thu, 25 April 2013 18:54]

Report message to a moderator

Re: GridCtrl performance [message #39784 is a reply to message #39776] Fri, 26 April 2013 13:33 Go to previous message
crydev is currently offline  crydev
Messages: 151
Registered: October 2012
Location: Netherlands
Experienced Member
Thanks Sender Ghost. I got it to work now and it is at least 10x faster. As others may be able to get the same problem as I have, I'll post my solution here.

My problem was mainly the use of templated structs that could have 7 different types, that also needed a different cast.

template <String (GetData) (SearchResult& instance, const int index)>
struct MemoryBlockValueConvert : public Convert
{
	virtual Value Format(const Value& q) const
	{
		return GetData(mMemoryScanner->GetSearchResult(), int(q));
	}
};

String GetAddress(SearchResult& instance, const int index)
{
	return FormatIntHexUpper(instance.mFirstMillionResults[index]->Address, 0);
}

String GetValue(SearchResult& instance, const int index)
{
	switch (mMemoryScanner->GetSearchResult().GetResultType())
	{
		case VALUETYPE_BYTE:
			return IntStr(((MemoryBlock<Byte>*)instance.mFirstMillionResults[index])->Buffer);
			break;
		case VALUETYPE_2BYTE:
			return IntStr(((MemoryBlock<short>*)instance.mFirstMillionResults[index])->Buffer);
			break;
		case VALUETYPE_4BYTE:
			return IntStr(((MemoryBlock<int>*)instance.mFirstMillionResults[index])->Buffer);
			break;
		case VALUETYPE_8BYTE:
			return IntStr64(((MemoryBlock<__int64>*)instance.mFirstMillionResults[index])->Buffer);
			break;
		case VALUETYPE_FLOAT:
			return DblStr(((MemoryBlock<float>*)instance.mFirstMillionResults[index])->Buffer);
			break;
		case VALUETYPE_DOUBLE:
			return DblStr(((MemoryBlock<double>*)instance.mFirstMillionResults[index])->Buffer);
			break;
		case VALUETYPE_STRING:
			return ((MemoryBlock<String>*)instance.mFirstMillionResults[index])->Buffer;
			break;
		default:
			return STRING_EMPTY;
			break;
	}
}


The rest is the same as Sender Ghost posted. Just call: SetVirtualCount(mFirstMillionResults.GetCount()) to add all the items to the ArrayCtrl.

Thanks again for helping me out! Smile
Previous Topic: [Minor bug & patch] ArrayCtrl and HeaderCtrl should use native resizing icons on X11.
Next Topic: pagination base ArrayCtrl
Goto Forum:
  


Current Time: Wed Nov 13 13:21:15 CET 2019

Total time taken to generate the page: 0.01716 seconds