ColorGrid unacceptable performance

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Wed Mar 01, 2006 12:30 pm

Hello Alexander,
What I'm talking about, is the following code in the InternalSetGridIndex:
Ah, I see. I thought you were talking about ClearGridIndex(); not to worry. Anyhow, it is interesting that this code:

Code: Select all

public void Add(T item)
{
      if (this._size == this._items.Length)
      {
            this.EnsureCapacity(this._size + 1);
      }
      this._items[this._size++] = item;
      this._version++;
}
should be significantly slower that this code:

Code: Select all

public void set_Item(int index, T value)
{
      if (index >= this._size)
      {
            ThrowHelper.ThrowArgumentOutOfRangeException();
      }
      this._items[index] = value;
      this._version++;
}
Could you, please, make a debug build when you are done with implementing all these fixes and performing some testing? It would be nice for me to have an optimized version, as we are about to release our application one of the parts of which depends on the ColorGrid performance.
The TeeChart for .NET team will make a debug build available before long, for sure, but at this time I cannot tell you exactly when that will be.
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

zema
Newbie
Newbie
Posts: 30
Joined: Tue Nov 15, 2005 5:00 am

Post by zema » Mon Mar 06, 2006 2:03 pm

Hi, Christopher
Ah, I see. I thought you were talking about ClearGridIndex(); not to worry. Anyhow, it is interesting that this code:

Code:
public void Add(T item)
{
if (this._size == this._items.Length)
{
this.EnsureCapacity(this._size + 1);
}
this._items[this._size++] = item;
this._version++;
}


should be significantly slower that this code:

Code:
public void set_Item(int index, T value)
{
if (index >= this._size)
{
ThrowHelper.ThrowArgumentOutOfRangeException();
}
this._items[index] = value;
this._version++;
}
Yes, you're right. The first method won't be much slower (one increment isn't a great drawback ;) ) than the second one unless it needs to reallocate the _items array. And there is no need to reallocate it if the List<T>..ctor(int) was used with proper capacity value or if the list was not recreated but cleared. So it's a matter of choice which way of filling the list to use.

Best regards,
Alexander

Post Reply