Test running time in Linux
2014-03-11 08:41
337 查看
/*This program is for testing the running time of for cycle.*/
#include<sys/time.h>
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i;
long int time;
struct timeval time_start;
struct timeval time_end;
gettimeofday((struct timeval*)&time_start,NULL);
for(i=0;i<10000;i++);
gettimeofday((struct timeval*)&time_end,NULL);
time=time_end.tv_usec-time_start.tv_usec;
printf("The running time of cycle is %d us",time);
}
#include<sys/time.h>
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i;
long int time;
struct timeval time_start;
struct timeval time_end;
gettimeofday((struct timeval*)&time_start,NULL);
for(i=0;i<10000;i++);
gettimeofday((struct timeval*)&time_end,NULL);
time=time_end.tv_usec-time_start.tv_usec;
printf("The running time of cycle is %d us",time);
}
相关文章推荐
- test video frame rate & bitrate code in linux
- [Linux Test Project] [PATCH] Fix an bad variable name erro in runltp script
- test run time of lines code in microsecond under Python3.6
- error: /lib64/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
- [linux] signal 0 for running process test
- Time/Timer in Linux vs. Windows
- error: /lib64/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
- System corrupt again (running in linux cd)
- the shutdown command in linux for shutdown in time or reboot
- Running Oracle's SQL Plus in Linux Ubuntu
- If running in the context of a test using the mocking API or bootstrap Grails correctly
- Attempt time threshold of job running in hadoop
- How to Change Timezone in your Linux System
- linux:Superblock mount time is in the future
- 关于Jedis连接Linux上的redis出现 DENIED Redis is running in protected mode问题的解决方案
- tap interfaces disabled in linux bridge - Carrier (IFF_RUNNING) <NO-CARRIER,BROADCAST,MULTICAST,UP>
- 路由器逆向分析------Running Debian MIPS Linux in QEMU
- 关于Jedis连接Linux上的redis出现 DENIED Redis is running in protected mode问题的解决方案
- enable parallel unit test running in visual studio 2010