C#计算某一些任务的执行时间(消耗时间)

 class Program
    {
        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();
        }
    }
原文地址:https://www.cnblogs.com/allen0118/p/4045705.html