Chinaunix首页 | 论坛 | 博客
  • 博客访问: 462781
  • 博文数量: 83
  • 博客积分: 92
  • 博客等级: 民兵
  • 技术积分: 690
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-25 13:33
文章分类

全部博文(83)

文章存档

2014年(3)

2013年(59)

2012年(16)

2011年(5)

我的朋友

分类: LINUX

2013-04-27 17:54:43

Linux测试程序运行的时间一般用:
gettimeofday()

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include


#define LOG_TAG "test"
#define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, fmt, ##args)  
#define LOGD(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, fmt, ##args)  
#define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, fmt, ##args)

struct timeval tstart,tend;
float timeuse;


int main(int argc, char **argv)
{
    gettimeofday(&tstart,NULL);
    //测试的程序。。
    gettimeofday(&tend,NULL);
    
    timeuse=1000000*(tend.tv_sec-tstart.tv_sec)+(tend.tv_usec-tstart.tv_usec);
    timeuse/=1000000;
    
    LOGI("timeuse,value:%f\n",timeuse);
    
    return 0;
}

阅读(5178) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~