Created
October 6, 2021 13:02
-
-
Save IISResetMe/3060c1c1f4e88e7e5fb6b1cbef95bda6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function target { | |
param($Caller = $((Get-PSCallStack)[0].Command)) | |
"'$Caller' called!" | |
} | |
function volunteerID { | |
target -Caller $MyInvocation.MyCommand | |
} | |
function callstackID { | |
target | |
} | |
$volunteerMeasure = Measure-Command { | |
1..10000 |ForEach-Object { volunteerID } | |
} | |
Write-Host "Caller passes ID explicitly: " -Foreground Cyan | |
Write-Host (" {0}" -f $volunteerMeasure) | |
Write-Host | |
$callstackMeasure = Measure-Command { | |
1..10000 |ForEach-Object { callstackID } | |
} | |
Write-Host "Callee unwinds callstack: " -Foreground Cyan | |
Write-Host (" {0}" -f $callstackMeasure) | |
Write-Host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment