用这个要比gettimeofday准确,精确到毫秒级
下面是使用timeb计算一个SQL的执行时间
#include <sys/types.h>
#include <sys/timeb.h>
#include <time.h>
struct timeb start,end;
ast_mutex_lock(&dblock);
ftime(&start);
deleteMSGResult = PQexec(conn, sqlcmd);
ftime(&end);
ast_mutex_unlock(&dblock);
unsigned long spend=0;
spend = end.millitm - start.millitm;
ast_log(LOG_NOTICE,"prepaid_staff_log: SQL spend time is %dms./n", (int)spend);
本文介绍了一种使用timeb结构体来精确测量SQL执行时间的方法,这种方法可以达到毫秒级精度,优于gettimeofday函数。
3494

被折叠的 条评论
为什么被折叠?



