Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
/*
2
 * copyright (c) 2006 Michael Niedermayer 
3
 *
4
 * This file is part of FFmpeg.
5
 *
6
 * FFmpeg is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * FFmpeg is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with FFmpeg; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
 */
20
 
21
/**
22
 * @file
23
 * high precision timer, useful to profile code
24
 */
25
 
26
#ifndef AVUTIL_TIMER_H
27
#define AVUTIL_TIMER_H
28
 
29
#include 
30
#include 
31
#include 
32
 
33
#include "config.h"
34
 
35
#if   ARCH_ARM
36
#   include "arm/timer.h"
37
#elif ARCH_BFIN
38
#   include "bfin/timer.h"
39
#elif ARCH_PPC
40
#   include "ppc/timer.h"
41
#elif ARCH_X86
42
#   include "x86/timer.h"
43
#endif
44
 
45
#if !defined(AV_READ_TIME) && HAVE_GETHRTIME
46
#   define AV_READ_TIME gethrtime
47
#endif
48
 
49
#ifdef AV_READ_TIME
50
#define START_TIMER                             \
51
    uint64_t tend;                              \
52
    uint64_t tstart = AV_READ_TIME();           \
53
 
54
#define STOP_TIMER(id)                                                    \
55
    tend = AV_READ_TIME();                                                \
56
    {                                                                     \
57
        static uint64_t tsum   = 0;                                       \
58
        static int tcount      = 0;                                       \
59
        static int tskip_count = 0;                                       \
60
        if (tcount < 2                        ||                          \
61
            tend - tstart < 8 * tsum / tcount ||                          \
62
            tend - tstart < 2000) {                                       \
63
            tsum+= tend - tstart;                                         \
64
            tcount++;                                                     \
65
        } else                                                            \
66
            tskip_count++;                                                \
67
        if (((tcount + tskip_count) & (tcount + tskip_count - 1)) == 0) { \
68
            av_log(NULL, AV_LOG_ERROR,                                    \
69
                   "%"PRIu64" decicycles in %s, %d runs, %d skips\n",     \
70
                   tsum * 10 / tcount, id, tcount, tskip_count);          \
71
        }                                                                 \
72
    }
73
#else
74
#define START_TIMER
75
#define STOP_TIMER(id) { }
76
#endif
77
 
78
#endif /* AVUTIL_TIMER_H */