Loading Performance in Grid for .Net

Article ID: 738
Last updated: 05 Jan, 2012
Article ID: 738
Last updated: 05 Jan, 2012
Revision: 1
Views: 1750
Posted: 29 Dec, 2005
by Meltreger B.
Updated: 05 Jan, 2012
by Meltreger B.
Problem

What's the most efficient way of displaying the numbers in Grid.NET from viewpoint of performance and speed. 




Cause




Action

We performed the following test (modifying our 1stGrid sample)

 

private int nticks;

private void timer1_Tick(object sender, System.EventArgs e)

{

for(int nRow = 1; nRow<=10; nRow++)

      for(int nCol =1; nCol<=5; nCol++)

      gridControl1[nRow,nCol].Style.Value = nticks.ToString();

nticks++;

}

 

private void Form1_Load(object sender, System.EventArgs e)

{

this.timer1.Start();

this.timer1.Interval = 100;

this.timer1.Tick += new EventHandler(timer1_Tick);

}

 

Performance was fine with Interval = 100.

 

We then ran this additional test comparing different ways to set style and value ranges:

 

private void button1_Click(object sender, System.EventArgs e)

{

      //gridControl1.LockUpdate(true);

      DateTime dtStart = DateTime.Now;

      for(int n =1; n <=1000; n++)

      {

           gridControl1[1,1].Style.Value = n.ToString();

      }

      DateTime dtStop = DateTime.Now;

      TimeSpan duration = dtStop - dtStart;

      Console.WriteLine(duration);

 

      Style style = new Style();

      dtStart = DateTime.Now;

      for(int n =1; n <=1000; n++)

      {

           style.Value = n.ToString();

           gridControl1.SetValueRange(Range.Cell(1,1), style);

      }

      dtStop = DateTime.Now;

      duration = dtStop - dtStart;

      Console.WriteLine(duration);

 

      dtStart = DateTime.Now;

      for(int n =1; n <=1000; n++)

      {

            style.Value = n.ToString();

            gridControl1.SetStyleRange(Range.Cell(1,1), style);

      }

      dtStop = DateTime.Now;

      duration = dtStop - dtStart;

      Console.WriteLine(duration);

      //gridControl1.LockUpdate(false);

}

 

Results of this test were:

 

00:00:01.6718750    //Value

00:00:01.5312500    //SetValueRange

00:00:01.5468750    //SetStyleRange

 

When gridControl1.LockUpdate(true); on very top and

gridControl1.LockUpdate(false); on very bottom of code above were uncommented, the results were as follows:

 

00:00:00.4218750     //Value

00:00:00.2968750     //SetValueRange

00:00:00.2812500     //SetStyleRange


This article was:   Helpful | Not helpful
Report an issue
Article ID: 738
Last updated: 05 Jan, 2012
Revision: 1
Views: 1750
Posted: 29 Dec, 2005 by Meltreger B.
Updated: 05 Jan, 2012 by Meltreger B.

Others in this category