|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __SQLSRVRESOURCEPROFILER_H__ |
|
17 #define __SQLSRVRESOURCEPROFILER_H__ |
|
18 |
|
19 #include <e32cmn.h> |
|
20 #include "SqlUtil.h" |
|
21 |
|
22 #ifdef _SQLPROFILER |
|
23 |
|
24 ///////////////////////////////// Heap max alloc ///////////////////////////////////// |
|
25 |
|
26 extern TBool TheSqlSrvProfilerMaxAllocEnabled; |
|
27 extern TInt TheSqlSrvProfilerMaxAllocSize; |
|
28 |
|
29 #define SQLPROFILER_REPORT_ALLOC(size) \ |
|
30 do \ |
|
31 { \ |
|
32 if(TheSqlSrvProfilerMaxAllocEnabled && (size) > TheSqlSrvProfilerMaxAllocSize) \ |
|
33 { \ |
|
34 TheSqlSrvProfilerMaxAllocSize = (size); \ |
|
35 } \ |
|
36 } \ |
|
37 while(0) |
|
38 |
|
39 ///////////////////////////////// IPC counters /////////////////////////////////////// |
|
40 |
|
41 enum TSqlIpcType |
|
42 { |
|
43 ESqlIpcRq, |
|
44 ESqlIpcRead, |
|
45 ESqlIpcWrite, |
|
46 // |
|
47 ESqlIpcLast |
|
48 }; |
|
49 |
|
50 extern TBool TheSqlSrvProfilerIpcEnabled; |
|
51 extern TInt TheSqlSrvProfilerIpc[]; |
|
52 extern TInt64 TheSqlSrvProfilerIpcBytes[]; |
|
53 |
|
54 #define SQLPROFILER_REPORT_IPC(type, bytes) \ |
|
55 do \ |
|
56 { \ |
|
57 if(TheSqlSrvProfilerIpcEnabled) \ |
|
58 { \ |
|
59 ++TheSqlSrvProfilerIpc[type]; \ |
|
60 TheSqlSrvProfilerIpcBytes[type] += bytes; \ |
|
61 } \ |
|
62 } \ |
|
63 while(0) |
|
64 |
|
65 ////////////////////////// IPC & SQL tracing related ///////////////////////////////// |
|
66 |
|
67 //Every time, when the SQL server starts, the time is stored in TheSqlSrvStartTime variable. |
|
68 //It is used later to calculate and trace the time offset of particular trace. |
|
69 extern TTime TheSqlSrvStartTime; |
|
70 |
|
71 //Level 1 IPC calls count. IPC calls types included: |
|
72 // ESqlSrvDbExec8, ESqlSrvDbExec16, ESqlSrvDbScalarFullSelect16, ESqlSrvStmtExec, |
|
73 // ESqlSrvStmtAsyncExec, ESqlSrvStmtBindExec, ESqlSrvStmtAsyncBindExec, ESqlSrvStmtNext, |
|
74 // ESqlSrvStmtBindNext; |
|
75 const TInt KIpcTraceTypeCount = 10; |
|
76 |
|
77 //A TSqlIpcTraceData array of KIpcTraceTypeCount elements is a member of the CSqlSrvSession class. |
|
78 //During the tracing, if level 1 or level 2 is enabled, all relevant information is summarized there. |
|
79 struct TSqlSrvIpcTraceData |
|
80 { |
|
81 TInt64 iExecutionTime; //The summary of the execution time spent in particular level 1 IPC call |
|
82 TInt iCount; //The IPC call count for particular level 1 call |
|
83 }; |
|
84 |
|
85 /////////////////// IPC & SQL tracing functions and macros /////////////////////////////// |
|
86 |
|
87 void SqlIpcStart(TUint& aIpcCounter, TUint32& aStartTicks, TUint aDbHandle); |
|
88 void SqlIpcEnd(TUint aIpcCounter, TUint32 aStartTicks, TSqlSrvFunction aFuncCode, |
|
89 TUint aDbHandle, TSqlSrvIpcTraceData aIpcTraceData[], TInt aRetCode); |
|
90 void SqlIpcError(TUint aIpcCounter, TSqlSrvFunction aFuncCode, TUint aDbHandle, TInt aError); |
|
91 void SqlPrintSql16(TUint aDbHandle, const TDesC& aSql, TBool aPrepare); |
|
92 void SqlPrintSql8(TUint aDbHandle, const TDesC8& aSql, TBool aPrepare); |
|
93 |
|
94 void SqlPrintDbCreate(TUint aDbHandle, const TDesC& aDbName); |
|
95 void SqlPrintDbOpen(TUint aDbHandle, const TDesC& aDbName); |
|
96 void SqlPrintDbClose(TUint aDbHandle); |
|
97 |
|
98 void SqlPrintServerStart(); |
|
99 void SqlPrintServerStop(); |
|
100 |
|
101 #define SQLPROFILER_IPC_START(aIpcCounter, aDbHandle) \ |
|
102 TUint32 startTicks = 0;\ |
|
103 SqlIpcStart(aIpcCounter, startTicks, aDbHandle) |
|
104 |
|
105 #define SQLPROFILER_IPC_END(aIpcCounter, aFuncCode, aDbHandle, aIpcTraceData, aRetCode) \ |
|
106 SqlIpcEnd(aIpcCounter, startTicks, aFuncCode, aDbHandle, aIpcTraceData, aRetCode) |
|
107 |
|
108 #define SQLPROFILER_IPC_ERROR(aIpcCounter, aFuncCode, aDbHandle, aError) \ |
|
109 SqlIpcError(aIpcCounter, aFuncCode, aDbHandle, aError) |
|
110 |
|
111 #define SQLPROFILER_SQL16_PRINT(aDbHandle, aSql, aPrepare) \ |
|
112 SqlPrintSql16(aDbHandle, aSql, aPrepare) |
|
113 |
|
114 #define SQLPROFILER_SQL8_PRINT(aDbHandle, aSql, aPrepare) \ |
|
115 SqlPrintSql8(aDbHandle, aSql, aPrepare) |
|
116 |
|
117 #define SQLPROFILER_DB_CREATE(aDbHandle, aDbName) \ |
|
118 SqlPrintDbCreate(aDbHandle, aDbName) |
|
119 |
|
120 #define SQLPROFILER_DB_OPEN(aDbHandle, aDbName) \ |
|
121 SqlPrintDbOpen(aDbHandle, aDbName) |
|
122 |
|
123 #define SQLPROFILER_DB_CLOSE(aDbHandle) \ |
|
124 SqlPrintDbClose(aDbHandle) |
|
125 |
|
126 #define SQLPROFILER_SERVER_START() \ |
|
127 SqlPrintServerStart() |
|
128 |
|
129 #define SQLPROFILER_SERVER_STOP() \ |
|
130 SqlPrintServerStop() |
|
131 |
|
132 /////////////////////////////////////////////////////////////////////////////////////// |
|
133 |
|
134 #else//_SQLPROFILER |
|
135 |
|
136 #define SQLPROFILER_REPORT_ALLOC(size) do {} while(0) |
|
137 #define SQLPROFILER_REPORT_IPC(type, bytes) do {} while(0) |
|
138 |
|
139 #define SQLPROFILER_IPC_START(aIpcCounter, aDbHandle) do {} while(0) |
|
140 #define SQLPROFILER_IPC_END(aIpcCounter, aFuncCode, aDbHandle, aIpcTraceData, aRetCode) do {} while(0) |
|
141 #define SQLPROFILER_IPC_ERROR(aIpcCounter, aFuncCode, aDbHandle, aError) do {} while(0) |
|
142 #define SQLPROFILER_SQL16_PRINT(aDbHandle, aSql, aPrepare) do {} while(0) |
|
143 #define SQLPROFILER_SQL8_PRINT(aDbHandle, aSql, aPrepare) do {} while(0) |
|
144 |
|
145 #define SQLPROFILER_DB_CREATE(aDbHandle, aDbName) do {} while(0) |
|
146 #define SQLPROFILER_DB_OPEN(aDbHandle, aDbName) do {} while(0) |
|
147 #define SQLPROFILER_DB_CLOSE(aDbHandle) do {} while(0) |
|
148 |
|
149 #define SQLPROFILER_SERVER_START() do {} while(0) |
|
150 #define SQLPROFILER_SERVER_STOP() do {} while(0) |
|
151 |
|
152 #endif//_SQLPROFILER |
|
153 |
|
154 /** |
|
155 This class can be used for collecting information regarding the SQL server resources usage. |
|
156 |
|
157 @see TSqlResourceProfiler |
|
158 @internalComponent |
|
159 */ |
|
160 NONSHARABLE_CLASS(TSqlSrvResourceProfiler) |
|
161 { |
|
162 public: |
|
163 static void StartL(const RMessage2&); |
|
164 static void StopL(const RMessage2&); |
|
165 static void ResetL(const RMessage2&); |
|
166 static void QueryL(const RMessage2&); |
|
167 |
|
168 }; |
|
169 |
|
170 #endif//__SQLSRVRESOURCEPROFILER_H__ |