Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
UltraTree performance issue
posted

Hello,

I 'm loading a tree in Outlook Express mode with approax 1000 folders (deepest folder level is 7) and 5000 items. It takes about 1 minute to load. I have analyzed performances with a tool, and I can see that most of time is spent in : SetCellValue and UltraTreeColumnSet.DirtySortForAssociatedNodesCollections(UltraTree) .

I have just 5 columns to set and if I remove columns sorting, result is the same. I have tested with 2007.3(hot fix 1061) and 2008.3 versions.

Is there any options to set to accelerate loading in that case ?

Thanks.

  • 660
    posted

    Hi,

    i have found this performance problem too - UltraTree is getting very slow adding new nodes IF you do something with the node inside the loop.

    Let me explain this with a short example:

    Example 1: This one is running very fast (<1 Second)

    private void button1_Click(object sender, EventArgs e)
            {
                UltraTreeNode node;
               
                Cursor.Current = Cursors.WaitCursor;
               
                treeBrowser.BeginUpdate();
                for (int i = 0; i <= 8000; i++)
                {
                    node = treeBrowser.Nodes.Add("entry: " + i.ToString());
                }
                treeBrowser.EndUpdate();
                Cursor.Current = Cursors.Default;
            }

    But: If you do it different it is getting very slow (6+ Seconds for the same Job!):

    private void button1_Click(object sender, EventArgs e)
            {
                UltraTreeNode node;
               
                Cursor.Current = Cursors.WaitCursor;
               
                treeBrowser.BeginUpdate();
                for (int i = 0; i <= 8000; i++)
                {
                    node = treeBrowser.Nodes.Add();
                    node.Text=
    "entry: " + i.ToString(); //this is making the thing slow!
                }
                treeBrowser.EndUpdate();
                Cursor.Current = Cursors.Default;
            }

    It doesn't matter if you try to set the .Text or the .Key - it's getting really slow :(

    I've tried the class that was posted above to reset the SortSettings but with no success (it's not getting faster)

    Well - i have to add about 8000 entries in one case... and about 25.000 in another case (i know it's stupid to have such amount of data at once but that's not my decision). The thing is, that it take only <1 to add such many nodes as long as i don't do anything with them. But of course i need to set a key, a tag, an icon etc... and if i do this, suddenly it takes 6-8 Seconds for the 8000 nodes and 60+ Seconds for the 25.000 entries :(

    This is way too slow for my application and i'm happy if someone has a good solution for this.

    Thanks a lot

  • 60
    Verified Answer
    posted

    I too had significant performance problems when adding a large number of UltraTreeNodes.  My solution was to temporarily disable sorting before the batch node creation using a special class I built that saves and restores a tree's sort settings.  I use it like this:

            _tree.BeginUpdate();
           
            // The 2nd parameter (true) tells the class to remove the sort settings after they are saved
            TreeSortSettings sortSettings = TreeSortSettings.FromTree(_tree, true);
            try
            {
                // Add a batch of nodes
            }
            finally
            {
                sortSettings.Restore();
                _tree.EndUpdate();   
            }

     

    Using BeginUpdate()/EndUpdate() alone didn't seem to help in any noticeable way.  Before using TreeSortSettings, it would take roughly 10 seconds to add 800 nodes in my tree's BeforeExpand event handler.  After using the TreeSortSettings class, the nodes are added and shown almost instantaneously.  Sorry for the lack of solid numbers, but take my word for it - the difference is night and day.

    I've attached the C# source for the TreeSortSettings class, feel free to use it.  It certainly solved my problem!

     

    Jim

  • 469350
    Offline posted in reply to Hugues Jeannerod

    Hi,

    I recommend that you Submit an incident to Infragistics Developer Support and ask them to report this to the developers to it can be investigated. If BeginUpdate does not help, then there's probably nothing more you can do here to make this more efficient but maybe there's something we can do internally to make it faster.