I just went through my (really complex) profile.ps1 and just added one function: function Invoke-Combine { [System.IO.FileInfo] [System.IO.Path]::Combine.Invoke($args) }
I replaced all my Join-Path $x $y -OutVariable $z | Test-Path calls with that and the 'Exists' property and whoa.
Before: ~4500 ms After: ~750 ms
I've always used .NET methods more anyway out of habit and familiarity but like cmdlets because they're pretty. I made my profile pretty. But pretty be damned, now. I like the extra 3 seconds off my day. I'll take that extra hour every 5 years.
1
u/endowdly_deux_over Apr 07 '21
Holy crap.
I just went through my (really complex) profile.ps1 and just added one function:
function Invoke-Combine { [System.IO.FileInfo] [System.IO.Path]::Combine.Invoke($args) }I replaced all my
Join-Path $x $y -OutVariable $z | Test-Pathcalls with that and the 'Exists' property and whoa.Before: ~4500 ms
After: ~750 ms
I've always used .NET methods more anyway out of habit and familiarity but like cmdlets because they're pretty. I made my profile pretty. But pretty be damned, now. I like the extra 3 seconds off my day. I'll take that extra hour every 5 years.