我正在调查 unix 系统上的日志记录性能。事情是我发现最昂贵的操作是获取日期。
目前我有这样的时间 -
timeb currTime;
struct tm localTime;
ftime( &currTime )
localtime_r(&currTime.time, &localTime);
我把它改成
struct timeval tv;
gettimeofday(&tv, NULL);
time_t curtime = tv.tv_sec;
struct tm localTime = *(localtime(&curtime));
并且没有看到任何性能改进。所以我想知道这可能不是在 unix 系统上获取本地时间的最快方法吗?
请分享你对此的想法。
提前感谢。