Skip to content

Instantly share code, notes, and snippets.

@IISResetMe
Created October 6, 2021 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IISResetMe/3060c1c1f4e88e7e5fb6b1cbef95bda6 to your computer and use it in GitHub Desktop.
Save IISResetMe/3060c1c1f4e88e7e5fb6b1cbef95bda6 to your computer and use it in GitHub Desktop.
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