diff libavutil/timer.h @ 2:897f711a7157

rearrange to work with autoconf
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Tue, 25 Sep 2012 15:55:33 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libavutil/timer.h	Tue Sep 25 15:55:33 2012 +0200
     1.3 @@ -0,0 +1,69 @@
     1.4 +/**
     1.5 + * @file
     1.6 + * high precision timer, useful to profile code
     1.7 + *
     1.8 + * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
     1.9 + *
    1.10 + * This file is part of FFmpeg.
    1.11 + *
    1.12 + * FFmpeg is free software; you can redistribute it and/or
    1.13 + * modify it under the terms of the GNU Lesser General Public
    1.14 + * License as published by the Free Software Foundation; either
    1.15 + * version 2.1 of the License, or (at your option) any later version.
    1.16 + *
    1.17 + * FFmpeg is distributed in the hope that it will be useful,
    1.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.20 + * Lesser General Public License for more details.
    1.21 + *
    1.22 + * You should have received a copy of the GNU Lesser General Public
    1.23 + * License along with FFmpeg; if not, write to the Free Software
    1.24 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
    1.25 + */
    1.26 +
    1.27 +#ifndef AVUTIL_TIMER_H
    1.28 +#define AVUTIL_TIMER_H
    1.29 +
    1.30 +#include <stdlib.h>
    1.31 +#include <stdint.h>
    1.32 +#include "config.h"
    1.33 +
    1.34 +#if   ARCH_ARM
    1.35 +#   include "arm/timer.h"
    1.36 +#elif ARCH_PPC
    1.37 +#   include "ppc/timer.h"
    1.38 +#elif ARCH_X86
    1.39 +#   include "x86/timer.h"
    1.40 +#endif
    1.41 +
    1.42 +#if !defined(AV_READ_TIME) && HAVE_GETHRTIME
    1.43 +#   define AV_READ_TIME gethrtime
    1.44 +#endif
    1.45 +
    1.46 +#ifdef AV_READ_TIME
    1.47 +#define START_TIMER \
    1.48 +uint64_t tend;\
    1.49 +uint64_t tstart= AV_READ_TIME();\
    1.50 +
    1.51 +#define STOP_TIMER(id) \
    1.52 +tend= AV_READ_TIME();\
    1.53 +{\
    1.54 +    static uint64_t tsum=0;\
    1.55 +    static int tcount=0;\
    1.56 +    static int tskip_count=0;\
    1.57 +    if(tcount<2 || tend - tstart < 8*tsum/tcount || tend - tstart < 2000){\
    1.58 +        tsum+= tend - tstart;\
    1.59 +        tcount++;\
    1.60 +    }else\
    1.61 +        tskip_count++;\
    1.62 +    if(((tcount+tskip_count)&(tcount+tskip_count-1))==0){\
    1.63 +        av_log(NULL, AV_LOG_ERROR, "%"PRIu64" dezicycles in %s, %d runs, %d skips\n",\
    1.64 +               tsum*10/tcount, id, tcount, tskip_count);\
    1.65 +    }\
    1.66 +}
    1.67 +#else
    1.68 +#define START_TIMER
    1.69 +#define STOP_TIMER(id) {}
    1.70 +#endif
    1.71 +
    1.72 +#endif /* AVUTIL_TIMER_H */