linux计算程序运行时间
时间:2010-12-27 来源:xwhbin
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
struct timeval tvpre, tvafter;
gettimeofday(&tvpre, NULL);
sleep(3); //这里是linux编程,这个sleep是秒为单位的
gettimeofday(&tvafter, NULL);
ast_log(LOG_NOTICE,"prepaid_staff_log: test spend time is %d msecond.\n", (tvafter.tv_sec-tvpre.tv_sec)*1000+(tvafter.tv_usec-tvpre.tv_usec)/1000);
#include <sys/time.h>
#include <time.h>
struct timeval tvpre, tvafter;
gettimeofday(&tvpre, NULL);
sleep(3); //这里是linux编程,这个sleep是秒为单位的
gettimeofday(&tvafter, NULL);
ast_log(LOG_NOTICE,"prepaid_staff_log: test spend time is %d msecond.\n", (tvafter.tv_sec-tvpre.tv_sec)*1000+(tvafter.tv_usec-tvpre.tv_usec)/1000);
相关阅读 更多 +