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