Created
February 24, 2019 23:01
-
-
Save evetsleep/ad9354bac6ae9c970d9d2eef183a9e85 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
$arrayList = New-Object -TypeName System.Collections.Generic.List[int] | |
0..9999 | ForEach-Object { $arrayList.Add($PSItem) } | |
$iterations = 1000 | |
$results = New-Object -TypeName System.Collections.Generic.List[PSCustomObject] | |
1..$iterations | ForEach-Object { | |
$number = Get-Random -Maximum 9999 | |
$resultObject = [PSCustomObject]@{ | |
whereMethod = (Measure-Command -Expression { $arrayList.where{$PSItem -eq $number} }).Milliseconds | |
whereObject = (Measure-Command -Expression { $arrayList | Where-Object { $PSItem -eq $number } }).Milliseconds | |
} | |
$results.Add($resultObject) | |
} | |
[PSCustomObject]@{ | |
Iterations = $results.count | |
whereMethod = [math]::Round(($results | Measure-Object -Property whereMethod -Average).Average,2) | |
whereObject = [math]::Round(($results | Measure-Object -Property whereObject -Average).Average,2) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment