|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QXACOMMON_H |
|
43 #define QXACOMMON_H |
|
44 |
|
45 #if defined(PLUGIN_QT_TRACE_ENABLED) \ |
|
46 || defined(PLUGIN_QT_SIGNAL_EMIT_TRACE_ENABLED) \ |
|
47 || defined(PROFILE_TIME) \ |
|
48 || defined(PROFILE_RAM_USAGE) \ |
|
49 || defined(PROFILE_HEAP_USAGE) |
|
50 # include <QDebug> |
|
51 #endif /* PLUGIN_QT_TRACE_ENABLED */ |
|
52 |
|
53 #ifdef PROFILE_RAM_USAGE |
|
54 # include <hal.h> |
|
55 #endif |
|
56 |
|
57 |
|
58 #ifdef PLUGIN_QT_TRACE_ENABLED |
|
59 # define QT_TRACE_FUNCTION_ENTRY qDebug() << __PRETTY_FUNCTION__ << ">" |
|
60 # define QT_TRACE_FUNCTION_EXIT qDebug() << __PRETTY_FUNCTION__ << "<" |
|
61 # define QT_TRACE_FUNCTION_ENTRY_EXIT qDebug() << __PRETTY_FUNCTION__ << "><" |
|
62 # define QT_TRACE1(v1) qDebug() << v1 |
|
63 # define QT_TRACE2(v1, v2) qDebug() << v1 << v2 |
|
64 #else |
|
65 # define QT_TRACE_FUNCTION_ENTRY |
|
66 # define QT_TRACE_FUNCTION_EXIT |
|
67 # define QT_TRACE_FUNCTION_ENTRY_EXIT |
|
68 # define QT_TRACE1(v1) |
|
69 # define QT_TRACE2(v1, v2) |
|
70 #endif /*PLUGIN_QT_TRACE_ENABLED*/ |
|
71 |
|
72 #ifdef PLUGIN_QT_SIGNAL_EMIT_TRACE_ENABLED |
|
73 # define SIGNAL_EMIT_TRACE1(v1) qDebug() << __PRETTY_FUNCTION__ << v1 |
|
74 #else |
|
75 # define SIGNAL_EMIT_TRACE1(v1) |
|
76 #endif /*PLUGIN_QT_SIGNAL_EMIT_TRACE_ENABLED*/ |
|
77 |
|
78 #ifdef PROFILE_TIME_ELAPSED |
|
79 # define TAG_TIME_PROFILING_BEGIN \ |
|
80 TTime beginProfilingTime; \ |
|
81 beginProfilingTime.HomeTime() |
|
82 |
|
83 # define TAG_TIME_PROFILING_END \ |
|
84 TTime endProfilingTime; \ |
|
85 endProfilingTime.HomeTime(); \ |
|
86 TTimeIntervalMicroSeconds diffInMicroSecs = endProfilingTime.MicroSecondsFrom(beginProfilingTime) |
|
87 |
|
88 # define QT_PRINT_TO_CONSOLE_TIME_DIFF \ |
|
89 qDebug() << "VPROFILEDAT: " << __PRETTY_FUNCTION__ << ": Time taken " << diffInMicroSecs.Int64() << " microseconds" |
|
90 #else /* Empty macros */ |
|
91 # define TAG_TIME_PROFILING_BEGIN |
|
92 # define TAG_TIME_PROFILING_END |
|
93 # define QT_PRINT_TO_CONSOLE_TIME_DIFF |
|
94 #endif /*PROFILE_TIME_ELAPSED*/ |
|
95 |
|
96 #ifdef PROFILE_RAM_USAGE |
|
97 # define TAG_RAM_PROFILING_BEGIN \ |
|
98 TInt beginProfilingRAM; \ |
|
99 TInt err1 = HAL::Get(HALData::EMemoryRAMFree, beginProfilingRAM) |
|
100 |
|
101 # define TAG_RAM_PROFILING_END \ |
|
102 TInt endProfilingRAM; \ |
|
103 TInt err2 = HAL::Get(HALData::EMemoryRAMFree, endProfilingRAM) |
|
104 |
|
105 # define QT_PRINT_TO_CONSOLE_RAM_DIFF \ |
|
106 if ((err1 == KErrNone) && (err2 == KErrNone)) \ |
|
107 { \ |
|
108 TInt diffRAM = (beginProfilingRAM - endProfilingRAM); \ |
|
109 if ( diffRAM > 0 ) \ |
|
110 { \ |
|
111 qDebug() << "VPROFILEDAT: " << __PRETTY_FUNCTION__ << ": " << diffRAM << " bytes of RAM used"; \ |
|
112 } \ |
|
113 else \ |
|
114 { \ |
|
115 qDebug() << "VPROFILEDAT: " << __PRETTY_FUNCTION__ << ": " << -(diffRAM) << " bytes of RAM freed"; \ |
|
116 } \ |
|
117 } \ |
|
118 else \ |
|
119 { \ |
|
120 qDebug() << "VPROFILEDAT: " << __PRETTY_FUNCTION__ << "Error1[" << err1 << "] Error2[" << err2; \ |
|
121 } |
|
122 |
|
123 #else /* Empty macros */ |
|
124 # define TAG_RAM_PROFILING_BEGIN |
|
125 # define TAG_RAM_PROFILING_END |
|
126 # define QT_PRINT_TO_CONSOLE_RAM_DIFF |
|
127 #endif /*PROFILE_RAM_USAGE*/ |
|
128 |
|
129 #ifdef PROFILE_HEAP_USAGE |
|
130 # define TAG_DEFAULT_HEAP_PROFILING_BEGIN \ |
|
131 TInt beginProfilingHEAPBiggestBlock; \ |
|
132 TInt beginProfilingHEAP = User::Available(beginProfilingHEAPBiggestBlock) \ |
|
133 |
|
134 # define TAG_DEFAULT_HEAP_PROFILING_END \ |
|
135 TInt endProfilingHEAPBiggestBlock; \ |
|
136 TInt endProfilingHEAP = User::Available(endProfilingHEAPBiggestBlock) \ |
|
137 |
|
138 # define QT_PRINT_TO_CONSOLE_HEAP_DIFF \ |
|
139 TInt diffHEAP = beginProfilingHEAP - endProfilingHEAP; \ |
|
140 if ( diffHEAP > 0 ) \ |
|
141 { \ |
|
142 qDebug() << "VPROFILEDAT: " << __PRETTY_FUNCTION__ << ": " << diffHEAP << " bytes in default HEAP used"; \ |
|
143 } \ |
|
144 else \ |
|
145 { \ |
|
146 qDebug() << "VPROFILEDAT: " << __PRETTY_FUNCTION__ << ": " << -(diffHEAP) << " bytes in default HEAP freed"; \ |
|
147 } |
|
148 #else /* Empty macros */ |
|
149 # define TAG_DEFAULT_HEAP_PROFILING_BEGIN |
|
150 # define TAG_DEFAULT_HEAP_PROFILING_END |
|
151 # define QT_PRINT_TO_CONSOLE_HEAP_DIFF |
|
152 #endif /*PROFILE_HEAP_USAGE*/ |
|
153 |
|
154 #endif /* QXACOMMON_H */ |