VC get system time
2018-01-11 19:02
148 查看
1、 ms timeGetTime()
#include <windows.h>
#include <stdio.h>
main()
{
DWORD t1, t2;
t1 = timeGetTime();
Sleep(1000);
t2 = timeGetTime();
printf("Begin Time: %u\n", t1);
printf("End Time: %u\n", t2);
printf("Lasting Time: %u\n",(t2-t1));
}
2、us
QueryPerformanceCount/QueryPerformanceFrequency:
#include <windows.h>
#include <stdio.h>
void main()
{
LARGE_INTEGER t1, t2, tc;
QueryPerformanceFrequency(&tc);
printf("Frequency: %u\n", tc.QuadPart);
QueryPerformanceCounter(&t1);
Sleep(1000);
QueryPerformanceCounter(&t2);
printf("Begin Time: %u\n", t1.QuadPart);
printf("End Time: %u\n", t2.QuadPart);
printf("Lasting Time: %u\n",( t2.QuadPart- t1.QuadPart));
}
3 Ktime
#include <stdio.h>
#include "KTimer.h"
main()
{
unsigned t;
KTimer timer;
timer.Start();
Sleep(1000);
t = timer.Stop();
printf("Lasting Time: %d\n",t);
}
#include <windows.h>
#include <stdio.h>
main()
{
DWORD t1, t2;
t1 = timeGetTime();
Sleep(1000);
t2 = timeGetTime();
printf("Begin Time: %u\n", t1);
printf("End Time: %u\n", t2);
printf("Lasting Time: %u\n",(t2-t1));
}
2、us
QueryPerformanceCount/QueryPerformanceFrequency:
#include <windows.h>
#include <stdio.h>
void main()
{
LARGE_INTEGER t1, t2, tc;
QueryPerformanceFrequency(&tc);
printf("Frequency: %u\n", tc.QuadPart);
QueryPerformanceCounter(&t1);
Sleep(1000);
QueryPerformanceCounter(&t2);
printf("Begin Time: %u\n", t1.QuadPart);
printf("End Time: %u\n", t2.QuadPart);
printf("Lasting Time: %u\n",( t2.QuadPart- t1.QuadPart));
}
3 Ktime
#include <stdio.h>
#include "KTimer.h"
main()
{
unsigned t;
KTimer timer;
timer.Start();
Sleep(1000);
t = timer.Stop();
printf("Lasting Time: %d\n",t);
}
相关文章推荐
- VC++获取当前系统时间日期 GetSystemTime()函数的用法
- VC++得到当前系统时间日期 GetSystemTime()
- VC中GetCurrentTime(), GetSystemTime( ), GetLocalTime( )的区别
- VC++获取当前系统时间日期 GetSystemTime()函数的用法
- VC++获取当前系统时间日期 GetSystemTime()函数的用法
- VC++获取当前系统时间日期 GetSystemTime()函数的用法
- VC++得到当前系统时间日期 GetSystemTime()
- VC++获取当前系统时间日期 GetSystemTime()函数的用法
- VC++获取当前系统时间日期 GetSystemTime()函数的用法
- VC++获取当前系统时间日期 GetSystemTime()函数的用法
- VC++获取当前系统时间日期 GetSystemTime()函数的用法
- GetSystemTime和GetLocalTime函数
- (转)windows平台时间函数性能比较QueryPerformanceCounter,GetTickCount,ftime,time,GetLocalTime,GetSystemTimeAsFileTime
- GetCurrentTime(),GetLocalTime(),GetSystemTime()之间的区别
- GetSystemTime和GetLocalTime函数
- GetSystemTime和GetLocalTime函数
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- GetSystemTimeAsFileTime讲解
- C++ Get System Time