powershell比较运算符包含vs大数组

时间:2017-02-23 10:36:09

标签: arrays powershell comparison-operators

想知道在数组搜索之后是否有机会提高性能o。目前它是16秒。

Measure-Command -Expression {

$a = @()
$b = @()
1..10000 | %{$a += $_}
1..10000 | %{$b += $_}

#Try to resize but still running 16 seconds
[array]::Resize([ref]$a,10000) 
[array]::Resize([ref]$b,10000)

foreach ($i in $a){
    if ($b -contains $i) {
        #write-host $i
    }
}

}

0 个答案:

没有答案