已更新至:
http://code.google.com/p/crifanlib/
中的:
http://code.google.com/p/crifanlib/source/browse/trunk/c/crifanLib.c
How to calculate the elapsed time
By Crifan Li
Date: 05.19 2008
1.For code
#include <time.h>
struct timeval tv_begin_mdct, tv_end_mdct;
int test_count=0; // test times
// every part of encoder time of one frame in milliseconds
long mdct_time = 0 ;
/* use for only test several times in a loop */
#define MAX_TEST_COUNT 15
//calculate mdct time of one of the firt ten frames
if( test_count <= MAX_TEST_COUNT )
gettimeofday(&tv_begin_mdct, 0);
………
Func();
………………
//calculate mdct time of one of the firt ten frames
if( test_count <= MAX_TEST_COUNT )
{
gettimeofday(&tv_end_mdct, 0);
mdct_time = tv_end_mdct.tv_usec – tv_begin_mdct.tv_usec ;
printf(" The mdct time of the %d frame is ttt%ld msn",test_count,mdct_time/1000);
}
2.For command
Use the Time tool/cmd:
Usage: time + YOUR_COMMOND
Eg:
[crifan@localhost fb]$ time ls
as352x_fb_sharp.ko cfbcopyarea.ko cfbfillrect.ko cfbimgblt.ko fb.ko
real
user
sys
转载请注明:在路上 » How to calculate the elapsed time