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