nengel@2: /** nengel@2: * @file nengel@2: * high precision timer, useful to profile code nengel@2: * nengel@2: * copyright (c) 2006 Michael Niedermayer nengel@2: * nengel@2: * This file is part of FFmpeg. nengel@2: * nengel@2: * FFmpeg is free software; you can redistribute it and/or nengel@2: * modify it under the terms of the GNU Lesser General Public nengel@2: * License as published by the Free Software Foundation; either nengel@2: * version 2.1 of the License, or (at your option) any later version. nengel@2: * nengel@2: * FFmpeg is distributed in the hope that it will be useful, nengel@2: * but WITHOUT ANY WARRANTY; without even the implied warranty of nengel@2: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU nengel@2: * Lesser General Public License for more details. nengel@2: * nengel@2: * You should have received a copy of the GNU Lesser General Public nengel@2: * License along with FFmpeg; if not, write to the Free Software nengel@2: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA nengel@2: */ nengel@2: nengel@2: #ifndef AVUTIL_TIMER_H nengel@2: #define AVUTIL_TIMER_H nengel@2: nengel@2: #include nengel@2: #include nengel@2: #include "config.h" nengel@2: nengel@2: #if ARCH_ARM nengel@2: # include "arm/timer.h" nengel@2: #elif ARCH_PPC nengel@2: # include "ppc/timer.h" nengel@2: #elif ARCH_X86 nengel@2: # include "x86/timer.h" nengel@2: #endif nengel@2: nengel@2: #if !defined(AV_READ_TIME) && HAVE_GETHRTIME nengel@2: # define AV_READ_TIME gethrtime nengel@2: #endif nengel@2: nengel@2: #ifdef AV_READ_TIME nengel@2: #define START_TIMER \ nengel@2: uint64_t tend;\ nengel@2: uint64_t tstart= AV_READ_TIME();\ nengel@2: nengel@2: #define STOP_TIMER(id) \ nengel@2: tend= AV_READ_TIME();\ nengel@2: {\ nengel@2: static uint64_t tsum=0;\ nengel@2: static int tcount=0;\ nengel@2: static int tskip_count=0;\ nengel@2: if(tcount<2 || tend - tstart < 8*tsum/tcount || tend - tstart < 2000){\ nengel@2: tsum+= tend - tstart;\ nengel@2: tcount++;\ nengel@2: }else\ nengel@2: tskip_count++;\ nengel@2: if(((tcount+tskip_count)&(tcount+tskip_count-1))==0){\ nengel@2: av_log(NULL, AV_LOG_ERROR, "%"PRIu64" dezicycles in %s, %d runs, %d skips\n",\ nengel@2: tsum*10/tcount, id, tcount, tskip_count);\ nengel@2: }\ nengel@2: } nengel@2: #else nengel@2: #define START_TIMER nengel@2: #define STOP_TIMER(id) {} nengel@2: #endif nengel@2: nengel@2: #endif /* AVUTIL_TIMER_H */