zedboard--linux测试程序所用时间
2013-10-22 20:30
302 查看
由于在搞zedboard的时候想测试一下程序所用的时间,用到了下面两种方法。
方法一:利用time函数,不过这个是秒级的。
#include "time.h"
time_t start.end;
float total;
main()
{
start=tme(NULL);
........
end=time(NULL);
total=difftime(end,start);
printf("use time is %f",total);
}
测试发现为0.00000秒,因为程序所用时间非常短,用这个方法不行,改用gettimeofday。
方法二:
#include "sys/time.h"
#include "math.h"
main()
{
struct timeval start,end;
float total;
gettimeofday(&start,NULL);
........
gettimeofday(&end,NULL);
total=1000000*(end.tv_sec-start.tv_sec)+end.tv_usec-start.tv_usec;
printf("use time is %f\n",total);
}
注意上面是sys/time.h,而不是time.h。以上这两种方法都亲测可以用。
另外记录和复习今天工作的细节。
Opencv: 在pc机运行的时候敲击的指令
g++ `pkg-config --cflags opencv` -o edge_detection.o edge_detection.cpp `pkg-config --libs opencv`
交叉编译(zedboard运行下)的指令
arm-xilinx-linux-gnueabi-g++ -I /home/xzy/OpenCV-2.3.1/install/include -I/home/xzy/OpenCV-2.3.1/install/include/opencv
-L /home/xzy/OpenCV-2.3.1/install/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann ./edge_detection.cpp -o ./edge_detection.o
另外还有注意事项就是一般这个程序都有带图片的参数,有时候忘记了会报出这样的错误。
zynq> ./edge_detection.o
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid
上面就是没有带参数。
QT:
在pc机运行的时候,在label静态显示一张图片,拖入,设置好大小,
在输入: ui->label->setPixmap(QPixmap("/opt/lena.bmp"))
ui->label->show();
但是要有读写这个照片的权限 哦,没有的话是不能显示的。
在zedboard上运行qt,交叉编译即可。
/usr/local/Trolltech/QtEmbedded-4.7.3-arm/bin/qmake –project
/usr/local/Trolltech/QtEmbedded-4.7.3-arm/bin/qmake
make
这在前面的博客中有讲的很清楚了,这里回忆一下。
方法一:利用time函数,不过这个是秒级的。
#include "time.h"
time_t start.end;
float total;
main()
{
start=tme(NULL);
........
end=time(NULL);
total=difftime(end,start);
printf("use time is %f",total);
}
测试发现为0.00000秒,因为程序所用时间非常短,用这个方法不行,改用gettimeofday。
方法二:
#include "sys/time.h"
#include "math.h"
main()
{
struct timeval start,end;
float total;
gettimeofday(&start,NULL);
........
gettimeofday(&end,NULL);
total=1000000*(end.tv_sec-start.tv_sec)+end.tv_usec-start.tv_usec;
printf("use time is %f\n",total);
}
注意上面是sys/time.h,而不是time.h。以上这两种方法都亲测可以用。
另外记录和复习今天工作的细节。
Opencv: 在pc机运行的时候敲击的指令
g++ `pkg-config --cflags opencv` -o edge_detection.o edge_detection.cpp `pkg-config --libs opencv`
交叉编译(zedboard运行下)的指令
arm-xilinx-linux-gnueabi-g++ -I /home/xzy/OpenCV-2.3.1/install/include -I/home/xzy/OpenCV-2.3.1/install/include/opencv
-L /home/xzy/OpenCV-2.3.1/install/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann ./edge_detection.cpp -o ./edge_detection.o
另外还有注意事项就是一般这个程序都有带图片的参数,有时候忘记了会报出这样的错误。
zynq> ./edge_detection.o
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid
上面就是没有带参数。
QT:
在pc机运行的时候,在label静态显示一张图片,拖入,设置好大小,
在输入: ui->label->setPixmap(QPixmap("/opt/lena.bmp"))
ui->label->show();
但是要有读写这个照片的权限 哦,没有的话是不能显示的。
在zedboard上运行qt,交叉编译即可。
/usr/local/Trolltech/QtEmbedded-4.7.3-arm/bin/qmake –project
/usr/local/Trolltech/QtEmbedded-4.7.3-arm/bin/qmake
make
这在前面的博客中有讲的很清楚了,这里回忆一下。
相关文章推荐
- linux下测试程序中各函数执行时间工具
- Linux下测试程序运行时间方法
- Linux下测试程序运行时间
- linux下测试程序中各函数执行时间工具
- linux下测试程序运行时间
- Linux下测试程序的运行时间
- c# 计算程序执行时间,计算一段代码执行所用的时间,测试效率
- Linux下测试程序运行时间
- linux下测试程序运行的时间
- 【Linux】【C语言】菜鸟学习日志(一) 一步一步学习在Linxu下测试程序的运行时间
- Linux中统计程序运行所用时间
- linux下测试程序运行的时间
- linux计算程序所用时间
- Linux下测试程序的运行时间
- Linux下测试程序运行时间模板
- linux下测试python程序执行时间
- 测试程序所用时间 C#
- 测试程序运行时间
- 在Ubuntu上为Android系统内置C可执行程序测试Linux内核驱动程序
- 测试SQL语句执行所用的时间