AD
Administrator
Syncfusion Team
August 10, 2005 04:01 PM UTC
You might take a look at the RefreshGrid performance sample. That is a sample where the grid holds the data and is optimized for performance.
>>I use cell values from custom type
Are you just letting the grid display the ToString on your object? Or, are you doing something else special to draw these cells?
Does your custom type implement ICloneable? If so, then by default, the grid is cloning these objects and this may have overhead associated with it. You can turn off the cloning using static IsCloneable and IsDisposable properties to indicate how the grid should handle these cellvalues.
GridStyleInfoStore.CellValueProperty.IsCloneable = false;
GridStyleInfoStore.CellValueProperty.IsDisposable = false;
GK
Georgi Kashev
August 11, 2005 08:45 AM UTC
RefreshGrid is optimized for updates of large part of the grid. It does not perform very well if random cells are updated frequently.
It seems that TraderGridTest is so fast because it refreshes only cells that are changed. RefreshGrid refreshes the whole grid.
I have add a performance counter in the QueryCellInfo handler just to count how much queries are made for a second. Another performance counter counts the updated cells in a second. It seems that the grid makes 3 times more queries than the changed cells (780/2400). However, if the cell updating frequency is very slow (10 cell/second) the grid behaves differently - it request 2 queries for each changed cell - one in the GridControl.Item and second in DrawClippedGrid. This is the performance that I wnat to have event with 1000 cell updates per second. Why does the grid behaves defferently with more frequent updates?
Code Sample:
private void gridControl1_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
{
queriesPerSecPC.RawValue++;
}
Random rand = new Random(Environment.TickCount);
private void timer1_Tick(object sender, System.EventArgs e)
{
Graphics g = gridControl1.CreateGridGraphics();
for (int i = 0; i < 10; i++)
{
// gridControl1.ResetVolatileData();
int row = rand.Next(this.gridControl1.RowCount) + 1;
int col = rand.Next(this.gridControl1.ColCount) + 1;
Syncfusion.Windows.Forms.Grid.GridStyleInfo cell = this.gridControl1[row,col];
((IDataCell)cell.CellValue).Assign(rand.Next(100));
Syncfusion.Windows.Forms.Grid.GridRangeInfo g1 = Syncfusion.Windows.Forms.Grid.GridRangeInfo.Cell(row, col);
Rectangle bounds = gridControl1.RangeInfoToRectangle(g1);
if (!bounds.IsEmpty)
{
// DrawClippedGrid method lets you simply draw the cells at the specified bounds directly to the graphics context.
gridControl1.DrawClippedGrid(g, bounds);
}
updatesDispPerSecPC.RawValue++;
}
}