[AHK]精确计时到秒

来源:互联网 发布:java实现自定义表单 编辑:程序博客网 时间:2024/06/02 09:11
DllCall("QueryPerformanceFrequency", "Int64*", QuadPart)DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)Sleep 1000DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)MsgBox % "Elapsed QPC time is " . Round((CounterAfter - CounterBefore)/QuadPart,0)return

C++版请参考

http://www.cppblog.com/deane/articles/113151.html

http://www.oschina.net/code/snippet_197161_6789

/////////////////////////////////////////////////#include <iostream>#include <windows.h>using namespace    std;////////////////////////////////////////////////void main(){    _LARGE_INTEGER time_start;    /*开始时间*/    _LARGE_INTEGER time_over;        /*结束时间*/    double dqFreq;                /*计时器频率*/    LARGE_INTEGER f;            /*计时器频率*/    QueryPerformanceFrequency(&f);    dqFreq=(double)f.QuadPart;    QueryPerformanceCounter(&time_start);    Sleep(1000);/*循环耗时*/    QueryPerformanceCounter(&time_over);     cout<<((time_over.QuadPart-time_start.QuadPart)/dqFreq)<<endl;//单位为秒,精度为1000 000/(cpu主频)微秒}


0 0