加速数组操作(Array)
Measure-Command { $ar = @() for ($x=0; $x -lt 10000; $x++) { $ar += $x } }
执行结果:3.301s
Measure-Command {
$ar = New-Object -TypeName System.Collections.ArrayList
for ($x=0; $x -lt 10000; $x++)
{
$ar.Add($x)
}
}
执行结果:0.047s
From:http://powershell.com/cs/blogs/tips/archive/2014/06/23/speeding-up-arrays.aspx