// startbench.cs using System; using System.Diagnostics; class Program { static void Main(string[] args) { string app = args[0]; // 起動する実行ファイルのパス int num = 10; // 繰り返し回数 Stopwatch sw = new Stopwatch(); sw.Start(); // 時間計測開始 for (int i = 0; i < num; i++) { Console.Write("."); Process p = new Process(); p.StartInfo.FileName = app; // p.StartInfo.Arguments = "……" // 起動オプションがある場合 p.Start(); // 起動 p.WaitForInputIdle(); // 起動完了待ち p.CloseMainWindow(); // ウィンドウを閉じる } sw.Stop(); // 時間計測終了 Console.WriteLine(); Console.WriteLine("起動回数:" + num); Console.WriteLine("合計時間:" + sw.Elapsed); Console.WriteLine("平均時間:" + sw.ElapsedMilliseconds / num + "ミリ秒"); } } // コンパイル方法:csc startbench.cs // 実行例:startbench.exe c:\WINDOWS\NOTEPAD.EXE