00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00026 #ifndef AVUTIL_TIMER_H
00027 #define AVUTIL_TIMER_H
00028
00029 #include <stdlib.h>
00030 #include <stdint.h>
00031 #include "config.h"
00032
00033 #if ARCH_ARM
00034 # include "arm/timer.h"
00035 #elif ARCH_BFIN
00036 # include "bfin/timer.h"
00037 #elif ARCH_PPC
00038 # include "ppc/timer.h"
00039 #elif ARCH_X86
00040 # include "x86/timer.h"
00041 #endif
00042
00043 #if !defined(AV_READ_TIME) && HAVE_GETHRTIME
00044 # define AV_READ_TIME gethrtime
00045 #endif
00046
00047 #ifdef AV_READ_TIME
00048 #define START_TIMER \
00049 uint64_t tend;\
00050 uint64_t tstart= AV_READ_TIME();\
00051
00052 #define STOP_TIMER(id) \
00053 tend= AV_READ_TIME();\
00054 {\
00055 static uint64_t tsum=0;\
00056 static int tcount=0;\
00057 static int tskip_count=0;\
00058 if(tcount<2 || tend - tstart < 8*tsum/tcount || tend - tstart < 2000){\
00059 tsum+= tend - tstart;\
00060 tcount++;\
00061 }else\
00062 tskip_count++;\
00063 if(((tcount+tskip_count)&(tcount+tskip_count-1))==0){\
00064 av_log(NULL, AV_LOG_ERROR, "%"PRIu64" decicycles in %s, %d runs, %d skips\n",\
00065 tsum*10/tcount, id, tcount, tskip_count);\
00066 }\
00067 }
00068 #else
00069 #define START_TIMER
00070 #define STOP_TIMER(id) {}
00071 #endif
00072
00073 #endif