添加一个类public class HighResolutionTimer
{
private long start;
private long stop;
private long frequency; public HighResolutionTimer()
{
QueryPerformanceFrequency (ref frequency);
} public void Start ()
{
QueryPerformanceCounter (ref start);
}  public void Stop ()
{
QueryPerformanceCounter (ref stop);
}  public float ElapsedTime
{
get
{
float elapsed = (((float)(stop - start)) / ((float) frequency));
return elapsed;
}
}  [System.Runtime.InteropServices.DllImport("KERNEL32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
private static extern bool QueryPerformanceCounter(  ref long performanceCount);
[System.Runtime.InteropServices.DllImport("KERNEL32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
private static extern bool QueryPerformanceFrequency(  ref long frequency);

调用:
HighResolutionTimer timer=new HighResolutionTimer();
///开始计时
timer.Start();//停止计时
timer.Stop();//获取时间
timer.ElapsedTime