最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

How to calculate the elapsed time

工作和技术 crifan 2752浏览 0评论

已更新至:

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

转载请注明:在路上 » How to calculate the elapsed time

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
79 queries in 0.154 seconds, using 22.15MB memory