Author Topic: can betterlist be re-tested?  (Read 3204 times)

Tama

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
can betterlist be re-tested?
« on: July 09, 2014, 07:07:25 AM »
I have a UITable subclass that overrides Sort. When changing UITable to UIGrid, I was amazed to find their sort functions different.

UITable:Sort (List<Transform> list)
UIGrid:Sort (BetterList<Transform> list)

So I had to investigate what this "BetterList" is. According to this post:
http://www.tasharen.com/forum/index.php?topic=1265.0
BetterList hasn't been tested since Unity 3.5
Do you think it could be re-evaluated to find out whether it is still necessary? It seems silly using both BetterList and List in the same codebase.

Besides changing the parameter type for my Sort override, I also had to change the comparitor type from Comparison<Transform> to BetterList<Transform>.CompareFunc
Why can't BetterList use Comparison<T> as its compare function?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: can betterlist be re-tested?
« Reply #1 on: July 09, 2014, 09:18:55 AM »
I'll test this out when I get home from work. As far as I know, Unity hasn't changed their mono since 3.0, so List shouldn't really have changed, but I'll do some different use cases of the two and show some results here. :)

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: can betterlist be re-tested?
« Reply #2 on: July 12, 2014, 02:37:00 PM »
I've done some performance tests with the StopWatch on certain tasks, do note that some of the tasks were unfairly biased against BetterList, so take em with a grain of salt.

https://docs.google.com/spreadsheets/d/1XgCK2SLthazRbaeXpQxmYuEL7MgKSkvMGhMB9_0y6FE/edit?usp=sharing

The main takeaway is that BetterList does not Sort well.. at all. :)

Generally, BetterList is a bit slower for standard actions, but faster for certain tasks - there's also memory concerns that should be tested properly, and I didn't have the time or equipment to do (no pro license (profiler) at home q_q), so someone else have to pick up that mantle.

I've attached the test.cs script I used to test it with, feel free to mess around with it and test for yourselves.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: can betterlist be re-tested?
« Reply #3 on: July 12, 2014, 04:37:56 PM »
TLDR version is that BetterList is better at Add and Remove (unless removing an item from the beginning), but worse for sorting. The benefit of add/remove is further compounded by the fact that BetterList doesn't cause GC allocations while doing so. As a result of the testing I've changed the UIPanel to keep a list of widgets in a regular List rather than BetterList, since it's sorted by depth. DrawCall and filling the widget buffers will continue to use BetterList, since vertices don't get sorted.

P.S. Grid will also use the regular List now.