Created
January 16, 2015 20:14
-
-
Save SimonWahlin/3c69d10a1c13aa439063 to your computer and use it in GitHub Desktop.
Contraproff empty pipelines
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 Init { | |
$File = "$env:tmp\testfile.tmp" | |
if(-Not (Test-Path -Path $File)){[Void](New-Item -Path $File -Type File)} | |
Start-Service -Name Spooler | |
} | |
Function Validate { | |
$File = "$env:tmp\testfile.tmp" | |
$FileStatus = if(Test-Path -Path $File){'Exists'}else{'Removed'} | |
$SrvStatus = (Get-Service -Name Spooler).Status | |
'{0,-7} {1}'-f $FileStatus, $SrvStatus | |
} | |
Function Measureit { | |
$File = "$env:tmp\testfile.tmp" | |
Init | |
$m1 = (Measure-Command -Expression { | |
Stop-Service -Name Spooler -Force | | |
Remove-Item $File | | |
Start-Service -Name Spooler | |
}).milliseconds | |
$r1 = Validate | |
$m2 = (Measure-Command -Expression { | |
Stop-Service -Name Spooler -Force | |
Remove-Item $File | |
Start-Service -Name Spooler | |
}).Milliseconds | |
$r2 = Validate | |
"Time:{0,-4}Result: {1,-17} | Time:{2,-4}Result: {3,-20}" -f $m1, $r1, $m2, $r2 | |
} | |
1..20 | %{measureit} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Results in the following:
Time:5 Result: Exists Stopped | Time:286 Result: Removed Running
Time:5 Result: Exists Stopped | Time:288 Result: Removed Running
Time:5 Result: Exists Stopped | Time:280 Result: Removed Running
Time:4 Result: Exists Stopped | Time:290 Result: Removed Running
Time:4 Result: Exists Stopped | Time:290 Result: Removed Running
Time:4 Result: Exists Stopped | Time:290 Result: Removed Running
Time:6 Result: Exists Stopped | Time:305 Result: Removed Running
Time:4 Result: Exists Stopped | Time:289 Result: Removed Running
Time:5 Result: Exists Stopped | Time:290 Result: Removed Running
Time:4 Result: Exists Stopped | Time:281 Result: Removed Running
Time:4 Result: Exists Stopped | Time:290 Result: Removed Running
Time:5 Result: Exists Stopped | Time:280 Result: Removed Running
Time:4 Result: Exists Stopped | Time:291 Result: Removed Running
Time:4 Result: Exists Stopped | Time:291 Result: Removed Running
Time:4 Result: Exists Stopped | Time:291 Result: Removed Running
Time:5 Result: Exists Stopped | Time:287 Result: Removed Running
Time:4 Result: Exists Stopped | Time:295 Result: Removed Running
Time:4 Result: Exists Stopped | Time:290 Result: Removed Running
Time:4 Result: Exists Stopped | Time:294 Result: Removed Running
Time:5 Result: Exists Stopped | Time:290 Result: Removed Running