Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6053244
  • 博文数量: 2759
  • 博客积分: 1021
  • 博客等级: 中士
  • 技术积分: 4091
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-11 14:14
文章分类

全部博文(2759)

文章存档

2019年(1)

2017年(84)

2016年(196)

2015年(204)

2014年(636)

2013年(1176)

2012年(463)

分类: LINUX

2013-04-28 06:13:28

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;
}

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