c++ 获取 毫秒级时间
作者:
星星之火666 | 来源:发表于
2019-04-24 14:20 被阅读0次
#include <iostream>
#include<sys/timeb.h>
using namespace std;
long long systemtime()
{
timeb t;
ftime(&t);
return t.time*1000+t.millitm;
}
int main()
{
long long start=systemtime();
int i=1000000000;
while(i--);
cout<<systemtime()-start<<" 毫秒";
return 0;
}
// 结果:1801 毫秒
#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
DWORD start = GetTickCount(); // 从操作系统启动所经过(elapsed/过去)的毫秒数,它的返回值是 DWORD
Sleep(2019);
cout << GetTickCount() - start << " 毫秒";
return 0;
}
本文标题:c++ 获取 毫秒级时间
本文链接:https://www.haomeiwen.com/subject/rjqggqtx.html
网友评论