C++ 时间函数(更新中...)
个人笔记,方便日后ctrl+c。
参考1: https://www.cnblogs.com/kex1n/p/3297607.html.
参考2: https://www.cnblogs.com/dwdxdy/p/3214905.html.
部分结论:
效率 | 精度 | |
---|---|---|
高 | GetTickCount | GetLocalTime(0.1微妙级) |
GetSystemTimeAsFileTime | GetSystemTimeAsFileTime(0.1微妙级) | |
time | GetTickCount(毫秒级) | |
_ftime | … | |
GetLocalTime | … | |
低 | QueryPerformanceCounter | … |
GetTickCount()----毫秒级,效率中
毫秒级时间函数,Windows API。返回从操作系统启动到现在所经过的毫秒数。大概系统连续运行49.71天后清零。
#include <Windows.h>
DWORD time;
time = GetTickCount();
time()&localtime----日期
秒级时间函数。获取系统当前日期年月日时分秒…
#include <ctime>
time_t time;
struct tm* date;
time(&t);
date = localtime(&t);
// date->tm_year years since 1900
// date->tm_mon mouths since January - [0, 11]
// ...