Better, stronger, faster … arrays

Using System.Collections.ArrayList to make faster arrays

PowerShell variables are extremely versatile, especially when using them as an array even if it is just using $var=@() and += to add new elements. One thing you will soon notice however is additions become very slow as the array grows in size, this is due to the array being fixed size on creation and to overcome the size limit, += creates a new array as a copy of the old data plus the new data. This results in extra memory reads and slows the process as the array grows.

So, how do we get around this ? Well there are a couple of options

Continue reading “Better, stronger, faster … arrays”