• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright (C) 2018 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************
18  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 
21 /**
22 ******************************************************************************
23 * @file ihevce_profile.h
24 *
25 * @brief
26 *  This file contains profiling related definitions
27 *
28 * @author
29 *    Ittiam
30 ******************************************************************************
31 */
32 
33 #ifndef _IHEVCE_PROFILE_H_
34 #define _IHEVCE_PROFILE_H_
35 
36 /*****************************************************************************/
37 /* Constant Macros                                                           */
38 /*****************************************************************************/
39 #ifndef PROFILE_ENABLE
40 #define PROFILE_ENABLE 0
41 #endif
42 
43 typedef struct
44 {
45     /* Note that time below will be in units of micro seconds */
46     /* Time before process call */
47     ULWORD64 u8_time_start;
48 
49     /* Time after process call */
50     ULWORD64 u8_time_end;
51 
52     /* Time taken by the last process call */
53     ULWORD64 u8_cur_time;
54 
55     /* Sum total of the time taken by process calls so far */
56     ULWORD64 u8_total_time;
57 
58     /*Avg time taken by a process so far */
59     ULWORD64 u8_avg_time;
60 
61     /* Peak time taken by a process so far */
62     ULWORD64 u8_peak_time;
63 
64     /* Number of process calls so far.
65      * Required for calc of avg time taken per process call */
66     UWORD32 u4_num_profile_calls;
67 
68     /* This flag is present to check that every
69      * profile_start() will have a corresponding
70      * arm_profile_sample_time_end() */
71     UWORD8 u1_sample_taken_flag;
72 
73 } profile_database_t;
74 
75 typedef struct
76 {
77     WORD32 tv_sec; /* Time in seconds.                            */
78     WORD32 tv_usec; /* Time in micro seconds.                      */
79 } timeval_t;
80 
81 /*****************************************************************************/
82 /* Function Declarations                                                     */
83 /*****************************************************************************/
84 void profile_sample_time_start();
85 void profile_sample_time_end();
86 void profile_print_stats();
87 int profile_get_avg_time(profile_database_t *ps_profile_data);
88 int profile_get_peak_time(profile_database_t *ps_profile_data);
89 int profile_convert_to_milli_sec(profile_database_t *ps_profile_data);
90 
91 ULWORD64 profile_sample_time();
92 
93 /* Should be called after each process call */
94 void profile_stop(profile_database_t *ps_profile_data, char *msg);
95 
96 /* Should be called before every process call */
97 void profile_start(profile_database_t *ps_profile_data);
98 
99 /* Should be called after codec instance initialization */
100 void init_profiler(profile_database_t *ps_profile_data);
101 
102 /* Should be called at the end of processing */
103 void profile_end(profile_database_t *ps_profile_data, char *msg);
104 
105 #if PROFILE_ENABLE
106 
107 #define PROFILE_INIT(x) init_profiler(x)
108 #define PROFILE_START(x) profile_start(x)
109 #define PROFILE_STOP(x, y) profile_stop(x, y)
110 #define PROFILE_END(x, y) profile_end(x, y)
111 
112 #else /* #if PROFILE_ENABLE */
113 
114 #define PROFILE_INIT(x)
115 #define PROFILE_START(x)
116 #define PROFILE_STOP(x, y)
117 #define PROFILE_END(x, y)
118 
119 #endif /* #if PROFILE_ENABLE */
120 
121 #endif /* _IHEVCE_PROFILE_H_ */
122