windows获取高精度时间戳 精度100ns

#include <stdio.h>
#include <Windows.h>

int main(void){
    LARGE_INTEGER ticks,Frequency;
    QueryPerformanceFrequency(&Frequency);//获取频率
    printf("频率:%d\n",Frequency.QuadPart);
    //频率一般为10000000 分辨率为100ns
    while (1)
    {
        QueryPerformanceCounter(&ticks);//获取一个时间戳
        printf("time(s):%.7lf\n",(double)ticks.QuadPart/(double)Frequency.QuadPart);
    }
    
    
}

 

posted @ 2022-03-27 22:10  『PTA00』  阅读(392)  评论(0编辑  收藏  举报