Last post May 15, 2008 08:51 AM by JeffreyABecker
Jan 09, 2008 04:57 PM|Actuality|LINK
I'm trying to ask a "which is best?" question. However, I'm sure that the answer depends upon the context. If you can bear with me, I'd just like to hear some discussion and some knowledge on the matter since there might not be clear winner.
Here's the question: Which size-changeable array is best for performance?
1. the VB array (ReDim)
2. Fiddling with the C# array via "Array.Copy" to a new array or some other size changing "trick" (if there is one)
3. C#'s list class
Jan 09, 2008 05:25 PM|TATWORTH|LINK
If the VB.NET is wriiten with OPTION STRICT ON, the code should be equally fast.
Jan 11, 2008 11:50 AM|Actuality|LINK
Jan 11, 2008 04:47 PM|TATWORTH|LINK
> Interesting, it sounds like VB often has an equal counterpart to C# in most of this stuff.
VB.NET is just as capable as C# and in at least one aspect is more capable! (With OPTION STRICT OFF it can late bind is cases where C# cannot)
Jan 11, 2008 07:42 PM|Actuality|LINK
Hmmm, for performance as well?
Jan 12, 2008 04:20 AM|TATWORTH|LINK
>Hmmm, for performance as well?
If option Strict ON is Specified for VB, then the performance is essentially the same as both produce the same ILC (Intermediate Language Code) that is JIT compiled to machine code.
May 15, 2008 08:51 AM|JeffreyABecker|LINK
System.Collections.Generic.List<T> will have the best performance.
Actually I lied. They're all fundamentally resizable array classes. They all do the same thing the same way so honestly it doesnt matter. They all have a random access time of O(1), and a reallocation penalty every time the list needs to be grown. I
say List<T> will have the best performance because it's known to implement this data structure correctly and has a bunch of useful functionality. Some operations like inserting an element at the front of the list will have O(n) runtime but I think that's
the worst you're going to get.