C# 计算某一些任务的执行时间

 static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

            sw.Start();
            for (int i = 0; i < 50000000; i++)
            {
                //Code
            }
            sw.Stop();

            Console.WriteLine("Total:" + sw.ElapsedMilliseconds + "ms");
            Console.ReadLine();
        }

你可能感兴趣的:(.net,C#)