はじめてのPowerShellのスクリプト
10回の実行時間の平均を出力する。
こちらを参考にしました。というかそのままです^q^
http://blogs.technet.com/b/stanabe/archive/2007/08/29/mesuring-execution-time-in-powershell.aspx
Measure-CommandAverage.ps1とでもしてあげてください。
param($factor) process { foreach( $i in 1..10 ) { $tms += (Measure-Command $factor).TotalMilliseconds Write-Host "." -noNewLine } Write-Output " " $ave = $tms/10 Write-Output $ave }
よい子の皆さんは引数で計測回数を変更できるぐらいはしときましょう。
つかいかたれい
.\Measure-CommandAverage.ps1 { .\hoge.exe }
最初は動かなくってビビった。
どうやら、スクリプトファイルの実行にはセキュリティポリシーの変更が必要らしい。
http://www.atmarkit.co.jp/fwin2k/operation/psh02/psh02_01.html
こちらのをそのままうちこむ
Set-ExecutionPolicy RemoteSigned