使用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();
}
}
}
结果: