Update contrib.
1 // Copyright (c) 2008-2010 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __SQLSRVRESOURCEPROFILER_H__
17 #define __SQLSRVRESOURCEPROFILER_H__
24 ///////////////////////////////// Heap max alloc /////////////////////////////////////
26 extern TBool TheSqlSrvProfilerMaxAllocEnabled;
27 extern TInt TheSqlSrvProfilerMaxAllocSize;
29 #define SQLPROFILER_REPORT_ALLOC(size) \
32 if(TheSqlSrvProfilerMaxAllocEnabled && (size) > TheSqlSrvProfilerMaxAllocSize) \
34 TheSqlSrvProfilerMaxAllocSize = (size); \
39 ///////////////////////////////// IPC counters ///////////////////////////////////////
50 extern TBool TheSqlSrvProfilerIpcEnabled;
51 extern TInt TheSqlSrvProfilerIpc[];
52 extern TInt64 TheSqlSrvProfilerIpcBytes[];
54 #define SQLPROFILER_REPORT_IPC(type, bytes) \
57 if(TheSqlSrvProfilerIpcEnabled) \
59 ++TheSqlSrvProfilerIpc[type]; \
60 TheSqlSrvProfilerIpcBytes[type] += bytes; \
65 ////////////////////////// IPC & SQL tracing related /////////////////////////////////
67 //Level 1 IPC calls count. IPC calls types included:
68 // ESqlSrvDbExec8, ESqlSrvDbExec16, ESqlSrvDbScalarFullSelect16, ESqlSrvStmtExec,
69 // ESqlSrvStmtAsyncExec, ESqlSrvStmtBindExec, ESqlSrvStmtAsyncBindExec, ESqlSrvStmtNext,
70 // ESqlSrvStmtBindNext;
71 const TInt KIpcTraceTypeCount = 10;
73 //A TSqlIpcTraceData array of KIpcTraceTypeCount elements is a member of the CSqlSrvSession class.
74 //During the tracing, if level 1 or level 2 is enabled, all relevant information is summarized there.
75 struct TSqlSrvIpcTraceData
77 TInt64 iExecutionTime; //The summary of the execution time spent in particular level 1 IPC call
78 TInt iCount; //The IPC call count for particular level 1 call
81 /////////////////// IPC & SQL tracing functions and macros ///////////////////////////////
83 void SqlIpcStart(TUint& aIpcCounter, TUint32& aStartTicks, TUint aDbHandle);
84 void SqlIpcEnd(TUint aIpcCounter, TUint32 aStartTicks, TSqlSrvFunction aFuncCode,
85 TUint aDbHandle, TSqlSrvIpcTraceData aIpcTraceData[], TInt aRetCode);
86 void SqlIpcError(TUint aIpcCounter, TSqlSrvFunction aFuncCode, TUint aDbHandle, TInt aError);
87 void SqlPrintSql16(TUint aDbHandle, const TDesC& aSql, TBool aPrepare);
88 void SqlPrintSql8(TUint aDbHandle, const TDesC8& aSql, TBool aPrepare);
90 void SqlPrintDbCreate(TUint aDbHandle, const TDesC& aDbName);
91 void SqlPrintDbOpen(TUint aDbHandle, const TDesC& aDbName);
92 void SqlPrintDbClose(TUint aDbHandle);
94 void SqlPrintServerStart();
95 void SqlPrintServerStop();
97 #define SQLPROFILER_IPC_START(aIpcCounter, aDbHandle) \
98 TUint32 startTicks = 0;\
99 SqlIpcStart(aIpcCounter, startTicks, aDbHandle)
101 #define SQLPROFILER_IPC_END(aIpcCounter, aFuncCode, aDbHandle, aIpcTraceData, aRetCode) \
102 SqlIpcEnd(aIpcCounter, startTicks, aFuncCode, aDbHandle, aIpcTraceData, aRetCode)
104 #define SQLPROFILER_IPC_ERROR(aIpcCounter, aFuncCode, aDbHandle, aError) \
105 SqlIpcError(aIpcCounter, aFuncCode, aDbHandle, aError)
107 #define SQLPROFILER_SQL16_PRINT(aDbHandle, aSql, aPrepare) \
108 SqlPrintSql16(aDbHandle, aSql, aPrepare)
110 #define SQLPROFILER_SQL8_PRINT(aDbHandle, aSql, aPrepare) \
111 SqlPrintSql8(aDbHandle, aSql, aPrepare)
113 #define SQLPROFILER_DB_CREATE(aDbHandle, aDbName) \
114 SqlPrintDbCreate(aDbHandle, aDbName)
116 #define SQLPROFILER_DB_OPEN(aDbHandle, aDbName) \
117 SqlPrintDbOpen(aDbHandle, aDbName)
119 #define SQLPROFILER_DB_CLOSE(aDbHandle) \
120 SqlPrintDbClose(aDbHandle)
122 #define SQLPROFILER_SERVER_START() \
123 SqlPrintServerStart()
125 #define SQLPROFILER_SERVER_STOP() \
128 ///////////////////////////////////////////////////////////////////////////////////////
132 #define SQLPROFILER_REPORT_ALLOC(size) do {} while(0)
133 #define SQLPROFILER_REPORT_IPC(type, bytes) do {} while(0)
135 #define SQLPROFILER_IPC_START(aIpcCounter, aDbHandle) do {} while(0)
136 #define SQLPROFILER_IPC_END(aIpcCounter, aFuncCode, aDbHandle, aIpcTraceData, aRetCode) do {} while(0)
137 #define SQLPROFILER_IPC_ERROR(aIpcCounter, aFuncCode, aDbHandle, aError) do {} while(0)
138 #define SQLPROFILER_SQL16_PRINT(aDbHandle, aSql, aPrepare) do {} while(0)
139 #define SQLPROFILER_SQL8_PRINT(aDbHandle, aSql, aPrepare) do {} while(0)
141 #define SQLPROFILER_DB_CREATE(aDbHandle, aDbName) do {} while(0)
142 #define SQLPROFILER_DB_OPEN(aDbHandle, aDbName) do {} while(0)
143 #define SQLPROFILER_DB_CLOSE(aDbHandle) do {} while(0)
145 #define SQLPROFILER_SERVER_START() do {} while(0)
146 #define SQLPROFILER_SERVER_STOP() do {} while(0)
151 This class can be used for collecting information regarding the SQL server resources usage.
153 @see TSqlResourceProfiler
156 NONSHARABLE_CLASS(TSqlSrvResourceProfiler)
159 static void StartL(const RMessage2&);
160 static void StopL(const RMessage2&);
161 static void ResetL(const RMessage2&);
162 static void QueryL(const RMessage2&);
166 #endif//__SQLSRVRESOURCEPROFILER_H__