• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <cstdio.h>
17 #include "hwe_osdep.h"
18 #include "hwe_source_record.h"
19 
20 namespace OHOS {
21 namespace ImagePlugin {
22 static HWE_PthreadMutex g_mutex;
23 
24 static int32_t g_mallocMemCount = 0;
25 static int32_t g_freeMemCount = 0;
26 
27 static int32_t g_initMutexCount = 0;
28 static int32_t g_destoryMutexCount = 0;
29 
30 static int32_t g_initCondCount = 0;
31 static int32_t g_destoryCondCount = 0;
32 
33 static int32_t g_initThreadCount = 0;
34 static int32_t g_destoryThreadCount = 0;
35 
RecordMallocMemCount()36 void RecordMallocMemCount()
37 {
38     HWE_PthreadMutexLock(&g_mutex);
39     g_mallocMemCount++;
40     HWE_PthreadMutexUnLock(&g_mutex);
41 }
42 
RecordFreeMemCount()43 void RecordFreeMemCount()
44 {
45     HWE_PthreadMutexLock(&g_mutex);
46     g_freeMemCount++;
47     HWE_PthreadMutexUnLock(&g_mutex);
48 }
49 
RecordInitMutexCount()50 void RecordInitMutexCount()
51 {
52     HWE_PthreadMutexLock(&g_mutex);
53     g_initMutexCount++;
54     HWE_PthreadMutexUnLock(&g_mutex);
55 }
56 
RecordDestoryMutexCount()57 void RecordDestoryMutexCount()
58 {
59     HWE_PthreadMutexLock(&g_mutex);
60     g_destoryMutexCount++;
61     HWE_PthreadMutexUnLock(&g_mutex);
62 }
63 
RecordInitCondCount()64 void RecordInitCondCount()
65 {
66     HWE_PthreadMutexLock(&g_mutex);
67     g_initCondCount++;
68     HWE_PthreadMutexUnLock(&g_mutex);
69 }
70 
RecordDestoryCondCount()71 void RecordDestoryCondCount()
72 {
73     HWE_PthreadMutexLock(&g_mutex);
74     g_destoryCondCount++;
75     HWE_PthreadMutexUnLock(&g_mutex);
76 }
77 
RecordInitThreadCount()78 void RecordInitThreadCount()
79 {
80     HWE_PthreadMutexLock(&g_mutex);
81     g_initThreadCount++;
82     HWE_PthreadMutexUnLock(&g_mutex);
83 }
84 
RecordDestoryThreadCount()85 void RecordDestoryThreadCount()
86 {
87     HWE_PthreadMutexLock(&g_mutex);
88     g_destoryThreadCount++;
89     HWE_PthreadMutexUnLock(&g_mutex);
90 }
91 
InitResourceInfo()92 void InitResourceInfo()
93 {
94     HWE_PthreadMutexInit(&g_mutex);
95 }
96 
DestroyResourceInfo()97 void DestroyResourceInfo()
98 {
99     HWE_PthreadMutexDestroy(&g_mutex);
100     HWE_LOGI("Memroy Info: malloc %d free %d", g_mallocMemCount, g_freeMemCount);
101     HWE_LOGI("Mutex Info: init %d destroy %d", g_initMutexCount, g_destoryMutexCount);
102     HWE_LOGI("Cond Info: init %d destroy %d", g_initCondCount, g_destoryCondCount);
103     HWE_LOGI("Thread Info: init %d destroy %d", g_initThreadCount, g_destoryThreadCount);
104 }
105 } // namespace ImagePlugin
106 } // namespace OHOS