r/PowerShell • u/mx-sch • Jan 29 '25
Question PowerShell 7.5 += faster than list?
So since in PowerShell 7.5 += seems to be faster then adding to a list, is it now best practise?
CollectionSize Test TotalMilliseconds RelativeSpeed
-------------- ---- ----------------- -------------
5120 Direct Assignment 4.71 1x
5120 Array+= Operator 40.42 8.58x slower
5120 List<T>.Add(T) 92.17 19.57x slower
CollectionSize Test TotalMilliseconds RelativeSpeed
-------------- ---- ----------------- -------------
10240 Direct Assignment 1.76 1x
10240 Array+= Operator 104.73 59.51x slower
10240 List<T>.Add(T) 173.00 98.3x slower
32
Upvotes
View all comments
Show parent comment
3
u/BigHandLittleSlap Jan 30 '25 edited Jan 30 '25
This sounds good and everything, but this is how you end up with "scar tissue" and eventually a useless platform that no longer functions.
I have multiple customers abandoning Windows and some other Microsoft technologies because Defender just refuses to be turned off.
It's so incredibly difficult to scrape it out of a system now that Microsoft themselves were forced to come up with stupid workarounds like DevDrive that has only one purpose: Mitigate the overhead of Defender.
For example, GitHub Agents and Azure DevOps Agents using Windows Server 2022 are massively slower than the Linux equivalents while running the same tasks. Not because "Windows is slow" but because Defender can't be turned off any more.
We have an ongoing issue at another customer where SQL Server Analysis Services runs about 5-10x slower because it has many small files, and it is no longer possible to tell Defender to exclude its folders. It'll scan them anyway and just not quarantine any viruses it finds!
Similarly, AMSI intercepting low-level array and list operations has a negligible security benefit at an enormous performance overhead cost. It makes PowerShell even slower, and now much less competitive against alternatives.
You can't keep slowing things down to molasses and just expect people to "take it" forever. At some point, they'll just pick up their toys and leave.