Share via


PowerShell: コマンドの実行時間を計測する

Windows Server World 2007? 10??? PowerShell ??????????????????????????????????Get-Command ????????????????????????????????????????????????????????????????????????????????????

PowerShell ???????? Measure-Command ????????????????????????PowerShell ????????????EXE ????????????????????????????????????

???????????????10????????????????????????

function measure10 ([scriptblock]$sb) {
     foreach ($i in 1..10) {
          $tms += (Measure-Command $sb).TotalMilliseconds
     }
     $tms/10
}

????????????????????????????????????????????????????????????

> measure10({ Get-Command | Where-Object {$_.Verb -eq "get"} | Format-Table Verb, Noun})

50.29031

50msec ???????????????????????? Get-Command ?????????????

> measure10({ Get-Command -Verb "get" | Format-Table Verb, Noun})

15.72206

???????? 1/3 ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????