diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-05-23 18:04:34 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-05-23 18:04:34 +0000 |
commit | b534c7f92a4e9690a3bf71022463fa6fd46a401a (patch) | |
tree | 81f0d4ea7dba158b270e68890d57379c1d78f7b5 /libavcodec/common.h | |
parent | 9fe690c88f9e74cf4addeb54da3a2b75f8bedd38 (diff) | |
download | ffmpeg-b534c7f92a4e9690a3bf71022463fa6fd46a401a.tar.gz |
some benchmarking code
Originally committed as revision 1901 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/common.h')
-rw-r--r-- | libavcodec/common.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libavcodec/common.h b/libavcodec/common.h index e83d277033..bbbc613dd2 100644 --- a/libavcodec/common.h +++ b/libavcodec/common.h @@ -1090,6 +1090,35 @@ if((y)<(x)){\ } #endif +#ifdef ARCH_X86 +static inline long long rdtsc() +{ + long long l; + asm volatile( "rdtsc\n\t" + : "=A" (l) + ); + return l; +} + +#define START_TIMER \ +static uint64_t tsum=0;\ +static int tcount=0;\ +static int tskip_count=0;\ +uint64_t tend;\ +uint64_t tstart= rdtsc();\ + +#define STOP_TIMER(id) \ +tend= rdtsc();\ +if(tcount<2 || tend - tstart < 4*tsum/tcount){\ + tsum+= tend - tstart;\ + tcount++;\ +}else\ + tskip_count++;\ +if(256*256*256*64%(tcount+tskip_count)==0){\ + fprintf(stderr, "%Ld dezicycles in %s, %d runs, %d skips\n", tsum*10/tcount, id, tcount, tskip_count);\ +} +#endif + #define CLAMP_TO_8BIT(d) ((d > 0xff) ? 0xff : (d < 0) ? 0 : d) /* avoid usage of various functions */ |