头文件:
#include <sys/time.h>
代码:
struct timeval begin;
struct timeval end;
gettimeofday(&begin, nullptr);
code…
gettimeofday(&end, nullptr);
uint32_t costTimeMs = (end.tv_sec1000 + end.tv_usec / 1000) - (begin.tv_sec1000 + begin.tv_usec / 1000);
linux中获取系统时间、计算函数耗时
于 2022-12-06 09:17:08 首次发布