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