ListBox ItemsSource performance
I'm having performance problems with ListBoxes. Setting the ItemsSource of a ListBox is very slow in NoesisGUI. It's especially a problem for MVVM which heavily depends on a data-driven workflow with ViewModels and Collections therein.
For a simple test I've used just a single ListBox and left out any UserControls, CodeBehinds and MVVM stuff which I should address in another topic.
A test with 100 items shows there's a lot of boxing and p/invoking going on behind the scenes. It's not only slow but also causes a lot of allocations.
http://imgur.com/MMtAjOI
Benchmark with 10,000 items
In Visual Studio 2015 the application launches in a blink of an eye.
http://imgur.com/R6T4wsm
In Unity 5.2 it takes minutes. Look at that GPU number
http://imgur.com/XSyqywD
The standalone build takes over 2 minutes to launch.
Now you may think what am I going to do with 10,000 items, but a card game like Scrolls (made in Unity) or Magic (about unique 12,000 cards) can display lists with several 100s or 1000s of cards.
For a simple test I've used just a single ListBox and left out any UserControls, CodeBehinds and MVVM stuff which I should address in another topic.
Code: Select all
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Height="768" Width="1024" MinHeight="720" MinWidth="1024"
>
<Grid>
<ListBox x:Name="MyList" FontSize="24" Height="500" Width="300" />
</Grid>
</UserControl>
Code: Select all
using Noesis;
using System.Collections.Generic;
using UnityEngine;
public class TestMyList : MonoBehaviour
{
public int amt = 10;
private void Start()
{
var gui = GetComponent<NoesisGUIPanel>();
var root = gui.GetContent();
var MyList = root.FindName<ListBox>("MyList");
List<string> myStrings = new List<string>(amt);
string text = "My String #";
for (int i = 0; i < amt; i++)
{
myStrings.Add(string.Concat(text, i));
}
MyList.ItemsSource = myStrings;
}
}
http://imgur.com/MMtAjOI
Benchmark with 10,000 items
In Visual Studio 2015 the application launches in a blink of an eye.
http://imgur.com/R6T4wsm
In Unity 5.2 it takes minutes. Look at that GPU number
http://imgur.com/XSyqywD
The standalone build takes over 2 minutes to launch.
Now you may think what am I going to do with 10,000 items, but a card game like Scrolls (made in Unity) or Magic (about unique 12,000 cards) can display lists with several 100s or 1000s of cards.
Re: ListBox ItemsSource performance
This behavior is totally unacceptable. There are several problems involved here, mainly a clipping problem but the fact that the clipping is not working is also exposing an inefficiency in the way databinding to c# properties is being done.
Could you please create a ticket for this issue?
Thanks and sorry for the inconvenience.
Could you please create a ticket for this issue?
Thanks and sorry for the inconvenience.
Re: ListBox ItemsSource performance
Created Issue #720.
ItemsControl is much faster than ListBox, so indeed it seems to be not only a problem with the ItemsSource.
Adding 10,000 items
ItemsControl: 30 seconds
ListBox: 2 and a half minute
ItemsControl is much faster than ListBox, so indeed it seems to be not only a problem with the ItemsSource.
Adding 10,000 items
ItemsControl: 30 seconds
ListBox: 2 and a half minute
Re: ListBox ItemsSource performance
Yes, although 30 seconds is still a lot of time...
Thanks for the report and feedback!
Thanks for the report and feedback!
Who is online
Users browsing this forum: Ahrefs [Bot], dstewart and 1 guest