加速数组操作(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
posted on 2014-07-01 10:38  momingliu11  阅读(348)  评论(0编辑  收藏  举报