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