C#計算執行時間
阿新 • • 發佈:2019-02-16
using System; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.Remoting.Messaging; using System.Text; namespace ConsoleApplication1 { static class Program { static void Main(string[] args) { int timeS = System.Environment.TickCount; int timeE = System.Environment.TickCount; var timeSpan = new Stopwatch(); timeSpan.Start(); Excute(() => { Console.WriteLine("test"); }); timeSpan.Stop(); Console.WriteLine(timeSpan.ElapsedMilliseconds); Console.ReadKey(); } public static void Excute(Action code) { code(); } } }