c语言计算函数消耗时间
c语言计算函数消耗时间:
#include <sys/time.h>
#include <unistd.h>
#include <unistd.h>
struct timeval tv1, tv2;
double sec =0;
gettimeofday(&tv1, 0);
HEGGTOPCOLLECTOR hTopCollector = eggTopCollector_new(0); // top 10
gettimeofday(&tv2, 0);
sec = (double)(tv2.tv_sec - tv1.tv_sec) + (double)(tv2.tv_usec - tv1.tv_usec) /1000000;
printf("time1: %f\n", sec);
double sec =0;
gettimeofday(&tv1, 0);
HEGGTOPCOLLECTOR hTopCollector = eggTopCollector_new(0); // top 10
gettimeofday(&tv2, 0);
sec = (double)(tv2.tv_sec - tv1.tv_sec) + (double)(tv2.tv_usec - tv1.tv_usec) /1000000;
printf("time1: %f\n", sec);