linux c 已经运行时间,Linux下,C语言程序运行时间计算(用于测定哪部分程序运行慢,以...

#define DEBUGSORT

#ifdef DEBUGSORT

#include

static unsigned long long usec(void){

struct timeval tv;

gettimeofday(&tv,NULL);

return (unsigned long long)tv.tv_sec*1000000+tv.tv_usec;

}

static struct {

const char *file;

int line;

unsigned long long usec;

}LOGTABLE[9000000];

static int LOGCOUNT = 0;

void putlog(const char*, const int);

void putlog(const char* file, const int line){

if(LOGCOUNT

LOGTABLE[LOGCOUNT].file =  file;

LOGTABLE[LOGCOUNT].line =  line;

LOGTABLE[LOGCOUNT].usec =  usec();

LOGCOUNT++;

}

}

void printlog(void);

void printlog(void){

int i;

for(i=0; i

fprintf(stderr, "%s:%d=%lld\n",

LOGTABLE[i].file,

LOGTABLE[i].line,

LOGTABLE[i].usec);

}

}

#define LOG putlog(__FILE__,__LINE__)

#define PRINTLOG printlog()

#else /* DEBUGSORT */

#define LOG

#define PRINTLOG

#endif /* DEBUGSORT */

(snowmail)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值