How to calculate the elapsed time

已更新至:

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     0m0.003s

user     0m0.001s

sys      0m0.002s



发表评论

电子邮件地址不会被公开。 必填项已用*标注

无觅相关文章插件,快速提升流量