PSCustomObject[] vs Hashtables: The ultimate object smackdown
summary
Concrete numbers and demos decide: building maps for 10,000 fake users and matching 5,000 keys with naive Where-Object runs tens of seconds (≈30s), ForEach-Parallel cuts that to ~21s, a Break-on-find loop ≈15s, converting users to a List and removing hits finishes ~100ms, building a lookup Hashtable keyed by email finishes ≈70ms. Converting JSON to PSCustomObject is prettier but slightly slower than Hashtable conversion, creating PSCustomObjects with the type accelerator is ~68ms vs New-Object ~200ms per 1000 runs, and containskey vs -contains shows large perf differences. Output formatting, ordered hashtables, nesting, and a LINQ-style join also appear and work.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 2:39PS objects vs hashtables
- 5:12Hashtables structure
- 11:34Creating PS objects
- 14:43Updating properties
- 21:03Output formatting
- 27:20Iterating through hashtables and PS objects
- 34:22Performance comparison
- 45:21Summary & Q&A
related talks
45mPSCustomObject vs Hashtables
47mPSCache: simple strategies for magnificent performance
46mCan we Make PowerShell… Blazingly Fast?!
44mPowerShell and MS Graph API Advanced, from Zero to Hero
44m99 Problems, but Slow PowerShell Ain't One!
51mDon't do that, do this instead: PowerShell worst practices and..
31mThe Incredible Extensible PSObject
01h 29mPerformance and Technique Tweaks: The Encore
