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 #define PROFILE_ENABLE 0 40 41 typedef struct 42 { 43 /* Note that time below will be in units of micro seconds */ 44 /* Time before process call */ 45 ULWORD64 u8_time_start; 46 47 /* Time after process call */ 48 ULWORD64 u8_time_end; 49 50 /* Time taken by the last process call */ 51 ULWORD64 u8_cur_time; 52 53 /* Sum total of the time taken by process calls so far */ 54 ULWORD64 u8_total_time; 55 56 /*Avg time taken by a process so far */ 57 ULWORD64 u8_avg_time; 58 59 /* Peak time taken by a process so far */ 60 ULWORD64 u8_peak_time; 61 62 /* Number of process calls so far. 63 * Required for calc of avg time taken per process call */ 64 UWORD32 u4_num_profile_calls; 65 66 /* This flag is present to check that every 67 * profile_start() will have a corresponding 68 * arm_profile_sample_time_end() */ 69 UWORD8 u1_sample_taken_flag; 70 71 } profile_database_t; 72 73 typedef struct 74 { 75 WORD32 tv_sec; /* Time in seconds. */ 76 WORD32 tv_usec; /* Time in micro seconds. */ 77 } timeval_t; 78 79 /*****************************************************************************/ 80 /* Function Declarations */ 81 /*****************************************************************************/ 82 void profile_sample_time_start(); 83 void profile_sample_time_end(); 84 void profile_print_stats(); 85 int profile_get_avg_time(profile_database_t *ps_profile_data); 86 int profile_get_peak_time(profile_database_t *ps_profile_data); 87 int profile_convert_to_milli_sec(profile_database_t *ps_profile_data); 88 89 ULWORD64 profile_sample_time(); 90 91 /* Should be called after each process call */ 92 void profile_stop(profile_database_t *ps_profile_data, char *msg); 93 94 /* Should be called before every process call */ 95 void profile_start(profile_database_t *ps_profile_data); 96 97 /* Should be called after codec instance initialization */ 98 void init_profiler(profile_database_t *ps_profile_data); 99 100 /* Should be called at the end of processing */ 101 void profile_end(profile_database_t *ps_profile_data, char *msg); 102 103 #if PROFILE_ENABLE 104 105 #define PROFILE_INIT(x) init_profiler(x) 106 #define PROFILE_START(x) profile_start(x) 107 #define PROFILE_STOP(x, y) profile_stop(x, y) 108 #define PROFILE_END(x, y) profile_end(x, y) 109 110 #else /* #if PROFILE_ENABLE */ 111 112 #define PROFILE_INIT(x) 113 #define PROFILE_START(x) 114 #define PROFILE_STOP(x, y) 115 #define PROFILE_END(x, y) 116 117 #endif /* #if PROFILE_ENABLE */ 118 119 #endif /* _IHEVCE_PROFILE_H_ */ 120