The Capacity will stay the same (in case of 100 items, 128).Ībout serialization, that depends on how the serializer works. When you clear the list, those items can theorically be collected, but as they are held by another array, the only thing Clear does is setting the Count to 0 and putting null to all items in the internal array. I was talking about memory usage, not about serialization size.Ī list of size 100 = the list itself in memory, plus an array of size 128 (check the capacity if you want to know the size of the internal array) + the data for the items. Implemented a version of StringSort in derived KeyedList class - July 17, 2012 Improved Stopwatch timing method and added relative differences calculation. ![]() HistoryĪdded Stopwatch tests results for Windows 7 64-bit system - July 7, 2012 These test results are in the download under SortTest.xsl. I also did tests on a 64-bit Windows 7 system to see if the relative difference results were different. Replacisng List.Sort() in a derived class or using the StringSort.Sort(List) overload yields a measurably quicker solution. Sorting strings using Microsoft quicksort implementation seems to have a large overhead. With my improved timing method, I found that Sedgewick is somewhat faster than StringSort (over 50% faster than standard Array.Sort). So from these elapsed ms tests, you can see that both Array.Sort() and List.Sort() (original Microsoft sort methods) are around 45% slower than StringSort. # Without CompareFun with Ordinal option this method is slower by about 3x There is also a overloaded version of Sort that takes an unsorted List parameter and returns a copy of a of a sorted list. The StringSort class Sort method has been changed to do an in-place Sort on string. A very small amount of time is used to do the two extra copies compared to the sort time. ![]() This is what is done by replacing the List.Sort method with my call to StringSort.Sort. sort array and refill contents of this (faster than directly sorting List)įrom my initial testing, I could see that it is faster to copy the List to a string, clear the list, sort the array using StringSort.Sort and refill the list with the result.
0 Comments
Leave a Reply. |