.NET监视程序运行时间

使用Stopwatch类(命名空间:System.Diagnostics;)

示例:

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFast;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var sw = new Stopwatch();
            sw.Start();
            List<Employee> employees = new List<Employee>
            {
                new Employee {ID = 1, Name = "Ringgo"},
                new Employee {ID = 2, Name = "Rex"},
                new Employee {ID = 1, Name = "Ringgo"}
            };
            var reslut = employees.Distinct();
            sw.Stop();
            Console.WriteLine(sw.ElapsedTicks);
            Console.WriteLine(reslut._ToJsonStr());
            Console.ReadKey();
        }
    }
}

 结果:

posted @ 2018-01-20 14:44  skybirdzw  阅读(250)  评论(0编辑  收藏  举报