0
点赞
收藏
分享

微信扫一扫

[AHK]精确计时到秒

眼君 2023-04-25 阅读 52


DllCall("QueryPerformanceFrequency", "Int64*", QuadPart)
DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)
Sleep 1000
DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
MsgBox % "Elapsed QPC time is " . Round((CounterAfter - CounterBefore)/QuadPart,0)
return



C++版请参考

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


/
#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 条评论