//结束计时 public void Stop() { if (UnixHelper.OS == "windows") { QueryPerformanceCounter(out stopTime); } else { UnixHelper.QueryPerformanceCounter(out stopTime); } }
//开始计时 public void Start() { //让等待线程工作 System.Threading.Thread.Sleep(0); if (UnixHelper.OS == "windows") { QueryPerformanceCounter(out startTime); } else { UnixHelper.QueryPerformanceCounter(out startTime); } }
//构造函数 public HiPerfTimer() { startTime = 0; stopTime = 0; if (UnixHelper.OS == "windows") { if (QueryPerformanceFrequency(out Frequence) == false) { //不支持高性能计时器 throw new System.ComponentModel.Win32Exception(); } } else { UnixHelper.QueryPerformanceFrequency(out Frequence); } }