Rendertable slow access to Cells

Posted by: mike on 24 September 2018, 8:35 pm EST

    • Post Options:
    • Link

    Posted 24 September 2018, 8:35 pm EST

    Here’s my test

     
                    for (int pass = 1; pass <= 10; pass++)
                    {
                        var t = new RenderTable(pass*100, 32);
                        var DT = DateTime.Now;
                        for (int r = 0; r < t.Rows.Count; r++)
                            for (int c = 0; c < t.Cols.Count; c++)
                            {
                                var Cell = t.Cells[r, c];
                            }
                        TimeSpan ts = DateTime.Now - DT;
                        textBox1.AppendText(t.Rows.Count.ToString() + " " + ts.TotalSeconds.ToString()+" "+new TimeSpan(ts.Ticks/pass).TotalSeconds.ToString()+"\r\n");
                    }
    
    

    Output: (truncated the values a bit for readability)

    100 0.17 0.17

    200 0.65 0.32

    300 1.49 0.49

    400 2.77 0.69

    500 4.27 0.85

    600 6.86 1.14

    700 9.79 1.39

    800 12.1 1.52

    900 15.2 1.69

    1000 19.1 1.91

    The traverse time for the table increases exponentially with the number of rows in the table. From 0.17sec per 100 rows to 1.91sec per 100 rows in a table with 1000 rows.

    Why?

  • Posted 25 September 2018, 5:53 am EST

    Hello,

    With the increase in the number of rows, processing time increases.

    Please try adding the following code before creation of C1PrintDocument:

    C1PrintDocument.MeasurementDevice = MeasurementDeviceEnum.Screen;
    C1PrintDocument.UsePrinterForDefaultPageSettings = false;
    
    

    Code can be added to the static void Program.Main() or to the form’s constructur before InitializeForm() call.

    If this does not help, kindly share your sample with us and we’ll go through it in order to assist you further.

    Best Regards,

    Esha

  • Posted 26 September 2018, 5:22 pm EST

    The sample code is in my original post. I am not using C1PrintDocument in it, I am just creating a RenderTable and accessing its cells. It takes 10 times longer to access a cell in a 1000 row table than in a 100 row table.

    Does your internal code have to search through the whole list of cells to access one cell?

  • Posted 28 September 2018, 12:52 am EST

    Hello Mike,

    I could observe the delay in rendering a table. Though C1Report is obsolete now (https://www.grapecity.com/en/forums/winforms-edition/c1report-in-maintenance-mo_1), allow me to check with the development team if we can improve the performance of RenderTable in any manner. I’ll get back to you once it is done.

    Best Regards,

    Esha

  • Posted 28 September 2018, 11:33 am EST

    I was using C1PrintDocument, Render objects and the C1Preview in order to print things.

    Am I wrong using these? Which classes should I use instead?

  • Posted 1 October 2018, 12:49 am EST

    Hello Mike,

    Am I wrong using these? Which classes should I use instead?

    It’s not wrong to use these. I just wanted to inform you about the latest news related to reports since C1PrintDocument is a part of “Reports for WinForms”.

    As per the development team:

    C1PrintDocument tables are logically infinite. Simply accessing an element at any position expands the table to include that position. Hence, by default, the Count property returns the maximum row or column number that has been accessed so far, i.e. each time when you access this property, it is calculated to return actual value. This behavior affects the perfomance in your case.



    To avoid this situation, use the below mentioned code:

    for (int pass = 1; pass <= 10; pass++)
    {
    
    int rowCount = pass * 100;
    int colCount = 32;
    var t = new RenderTable(rowCount, colCount);
    var DT = DateTime.Now;
    for (int r = 0; r < rowCount; r++)
    for (int c = 0; c < colCount; c++)
    {
    
    var Cell = t.Cells[r, c];
    }
    
    TimeSpan ts = DateTime.Now - DT;
    
    textBox1.AppendText(t.Rows.Count.ToString() +
    
    " " + ts.TotalSeconds.ToString() + " " + new TimeSpan(ts.Ticks / pass).TotalSeconds.ToString() + "\r\n");
    }
    

    Best Regards,

    Esha

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels