#Lets create some test data $ItemCount = 10000 $Iterations = 10000 $ItemArray = [string[]]::new($ItemCount) #Pre-initialize your arrays with a length #Now we fill the array with random data $Randomizer = [Random]::new() for ($I = 0; $I -lt $ItemCount; $I++) { $ItemArray[$I] = [GUID]::NewGuid().ToString() } #Now lets create another array. This array will be used to query the original to see if stuff exists in it. #We will also make sure half the entries do not exist $QueryArray = @(0)*$Iterations for ($I = 0; $I -lt $Iterations/2; $I++) { $QueryArray[$I] = [GUID]::NewGuid().ToString() } for ($I = $Iterations/2; $I -lt $Iterations; $I++) { $QueryArray[$I] = $ItemArray[$Randomizer.Next(0,$ItemArray.Length)] } $UnsortedMetrics = Measure-Command { for ($I = 0; $I -lt $Iterations; $I++) { $null=$ItemArray.Contains($QueryArray[$I]) } } #Now we sort it and try again with BinarySearch [Array]::Sort($ItemArray) $SortedMetrics = Measure-Command { for ($I = 0; $I -lt $Iterations; $I++) { $null=[Array]::BinarySearch($ItemArray, $QueryArray[$I]) } }