本文介绍了在Linux环境下,如何使用printf函数添加时间戳来辅助代码调试,特别是在计算camera帧率时,通过打印时间间隔来估算帧率。示例代码展示了具体的使用方法,输出格式为2023-05-23 17:30:05.345。
摘要由CSDN通过智能技术生成
tm_t = localtime(&time.tv_sec);
if(NULL != tm_t) {
sprintf(ptime,"%04d-%02d-%02d %02d:%02d:%02d.%03ld",
tm_t->tm_year+1900,
tm_t->tm_mon+1,
tm_t->tm_mday,
tm_t->tm_hour,
tm_t->tm_min,
tm_t->tm_sec,
time.tv_usec/1000);
return;
int main(void) {
char nowTime[256] = {0};
getDataTime((char *)nowTime)
printf("time: %s",nowTime);
return 0;
输出的log:
2023-05-23 17:30:05.345
#ifdef __TIME_TRACE_DEBUG__
# define TIME_TRACE tt::record Tt_ReCoRd_AvOiD_ReDeF(new tt::func_time_info(__func__));
# define TIME_TRACE_RESET tt::ctrl::inst()->reset();
# define TIME_TRACE_FORCE_PRINT tt::ctrl::inst()->ctrl_print();
# ifdef __TIME_TRACE_INER_DEBUG__
# define TT_DEBUG printf("", __func__, __LINE__),printf
# else
# define TT_DEBUG
# endif //__TIME_TRACE_INER_DEBUG__
#else // __TIME_TRACE_DEBUG__
# define TIME_TRACE_RESET
# define TIME_TRACE
# define TIME_TRACE_FORCE_PRINT
# define TT_DEBUG
#endif // __TIME_TRACE_DEBUG__
do_gettimeofday kernel space API
gettimeofday user space API
driver中的printf用了do_gettimeofday(*timeval)
printf(%ld)
aa353361067:
AIS Camera流程-opencamera
gfhappy1314:
AIS camera 开发调试记录--持续更新
以梦为马无处可栖: