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 <inttypes.h>
00032
00033 #include "config.h"
00034
00035 #if ARCH_ARM
00036 # include "arm/timer.h"
00037 #elif ARCH_BFIN
00038 # include "bfin/timer.h"
00039 #elif ARCH_PPC
00040 # include "ppc/timer.h"
00041 #elif ARCH_X86
00042 # include "x86/timer.h"
00043 #endif
00044
00045 #if !defined(AV_READ_TIME) && HAVE_GETHRTIME
00046 # define AV_READ_TIME gethrtime
00047 #endif
00048
00049 #ifdef AV_READ_TIME
00050 #define START_TIMER \
00051 uint64_t tend; \
00052 uint64_t tstart = AV_READ_TIME(); \
00053
00054 #define STOP_TIMER(id) \
00055 tend = AV_READ_TIME(); \
00056 { \
00057 static uint64_t tsum = 0; \
00058 static int tcount = 0; \
00059 static int tskip_count = 0; \
00060 if (tcount < 2 || \
00061 tend - tstart < 8 * tsum / tcount || \
00062 tend - tstart < 2000) { \
00063 tsum+= tend - tstart; \
00064 tcount++; \
00065 } else \
00066 tskip_count++; \
00067 if (((tcount + tskip_count) & (tcount + tskip_count - 1)) == 0) { \
00068 av_log(NULL, AV_LOG_ERROR, \
00069 "%"PRIu64" decicycles in %s, %d runs, %d skips\n", \
00070 tsum * 10 / tcount, id, tcount, tskip_count); \
00071 } \
00072 }
00073 #else
00074 #define START_TIMER
00075 #define STOP_TIMER(id) { }
00076 #endif
00077
00078 #endif