diff -r 000000000000 -r 08ec8eefde2f persistentstorage/sql/INC/SqlResourceProfiler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/persistentstorage/sql/INC/SqlResourceProfiler.h Fri Jan 22 11:06:30 2010 +0200 @@ -0,0 +1,244 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Symbian SQL Resource Profiler header file +// +// + +/** + @file + @internalComponent +*/ +#ifndef __SQLRESOURCEPROFILER_H__ +#define __SQLRESOURCEPROFILER_H__ + +#include + +/** +Symbian SQL profiling interface. +TSqlResourceProfiler class is used for: + +@code + + - Retrieving the current state of the SQL server heap and SQLite heap stats. + Example: + RSqlDatabase db; + //initialize the db object.... + ... + TSqlResourceProfiler profiler(db); + profiler.Start(TSqlResourceProfiler::ESqlCounterMemory);//Start the profiling + profiler.Reset(TSqlResourceProfiler::ESqlCounterMemory);//Zero the porfiling counters + .... + profiler.Stop(TSqlResourceProfiler::ESqlCounterMemory); //Stop the profiling + TBuf8<128> res; + profiler.Query(TSqlResourceProfiler::ESqlCounterMemory, res); + The format of the retrieved counters is: + ";;;; + ;;; + ;; + ;;;"; + This service can be used only if the SQL code is compiled with the _SQLPROFILER macro. + + - Retrieving the size of the biggest memory block ever allocated by the Symbian SQL server and SQLite. + Example: + RSqlDatabase db; + //initialize the db object.... + ... + TSqlResourceProfiler profiler(db); + ..... + profiler.Start(TSqlResourceProfiler::ESqlCounterMaxAlloc);//Start the profiling + ..... + TBuf8<32> res; + profiler.Query(TSqlResourceProfiler::ESqlCounterMaxAlloc, res); + ... + profiler.Reset(TSqlResourceProfiler::ESqlCounterMaxAlloc);//Reset the profiling + .... + profiler.Stop(TSqlResourceProfiler::ESqlCounterMaxAlloc); + The format of the retrieved counters is: + ";"; + This service can be used only if the SQL code is compiled with the _SQLPROFILER macro. + + - Retrieving the number of the file system calls made by the OS porting layer and the amount of written/read data. + Example: + RSqlDatabase db; + //initialize the db object.... + ... + TSqlResourceProfiler profiler(db); + ..... + profiler.Start(TSqlResourceProfiler::ESqlCounterFileIO);//Start the profiling + ..... + TBuf8<300> res; + profiler.Query(TSqlResourceProfiler::ESqlCounterFileIO, res); + ..... + profiler.Reset(TSqlResourceProfiler::ESqlCounterFileIO);//Reset the profiling + .... + profiler.Stop(TSqlResourceProfiler::ESqlCounterFileIO); + The format of the retrieved data is: + ";;;; + ;;;;; + ;;;; + ;;;; + ;;;;<0>; + ;;" + Note that currently the file operations are buffered, so the retrieved results will be about the operations executed on a + RFileBuf64 objects. + This service can be used only if the SQL code is compiled with the _SQLPROFILER macro. + + - Retrieving information regading the current SQL/SQLite configuration. + Example: + RSqlDatabase db; + //initialize the db object.... + ... + TSqlResourceProfiler profiler(db); + TBuf8<128> res; + profiler.Query(TSqlResourceProfiler::ESqlCounterConfig, res); + The format of the retrieved numbers is: + ";;;;"; + + - Retrieving the number of the OS porting layer calls made by SQLite. + Example: + RSqlDatabase db; + //initialize the db object.... + ... + TSqlResourceProfiler profiler(db); + ..... + profiler.Start(TSqlResourceProfiler::ESqlCounterOsCall);//Start the profiling + ..... + TBuf8<300> res; + profiler.Query(TSqlResourceProfiler::ESqlCounterOsCall, res); + ..... + profiler.Reset(TSqlResourceProfiler::ESqlCounterOsCall);//Reset the profiling + .... + profiler.Stop(TSqlResourceProfiler::ESqlCounterOsCall); + The format of the retrieved data is: + ";;;; + ;;;;; + ;;;; + ;;;; + ;;;" + This service can be used only if the SQL code is compiled with the _SQLPROFILER macro. + + - Retrieving the OS porting layer call times in microseconds per call type. + Example: + RSqlDatabase db; + //initialize the db object.... + ... + TSqlResourceProfiler profiler(db); + ..... + profiler.Start(TSqlResourceProfiler::ESqlCounterOsCallTime);//Start the profiling + ..... + TBuf8<300> res; + profiler.Query(TSqlResourceProfiler::ESqlCounterOsCallTime, res); + ..... + profiler.Reset(TSqlResourceProfiler::ESqlCounterOsCallTime);//Reset the profiling + .... + profiler.Stop(TSqlResourceProfiler::ESqlCounterOsCallTime); + The format of the retrieved data is: + ";;;; + ;;;;; + ;;;; + ;;;; + ;;;" + This service can be used only if the SQL code is compiled with the _SQLPROFILER macro. + + - Retrieving the OS porting layer call times in microseconds per call type plus adding a log entry + for each call. The returned information is the same as for the previous profiling type. + But for each OS porting layer call an entry is added to the log file (epocwind.out). + The format of the log entry is: + <'M'/'J'>,<'Call Id'>,<#Counter>,,,,,, + Note: ESqlCounterOsCallDetails and ESqlCounterOsCallTime profiles cannot be used together. + + - Retrieving the number of the IPC calls and IPC read/write operations. + Example: + RSqlDatabase db; + //initialize the db object.... + ... + TSqlResourceProfiler profiler(db); + ..... + profiler.Start(TSqlResourceProfiler::ESqlCounterIpc);//Start the profiling + ..... + TBuf8<300> res; + profiler.Query(TSqlResourceProfiler::ESqlCounterIpc, res); + ..... + profiler.Reset(TSqlResourceProfiler::ESqlCounterIpc);//Reset the profiling + .... + profiler.Stop(TSqlResourceProfiler::ESqlCounterIpc); + The format of the retrieved data is: + ";;;;; + This service can be used only if the SQL code is compiled with the _SQLPROFILER macro. + + - Tracing the executed SQL statements and IPC calls. + The folowing tracing configurations can be used (pased as a configuration parameter in TSqlResourceProfiler::Start()): + - "L0" - [default] tracing level 0. IPC traces disabled; + - "L1" - tracing level 1. Only the most important IPC calls are traced: + ESqlSrvDbExec8, ESqlSrvDbExec16, ESqlSrvDbScalarFullSelect16, ESqlSrvStmtExec, + ESqlSrvStmtAsyncExec, ESqlSrvStmtBindExec, ESqlSrvStmtAsyncBindExec, ESqlSrvStmtNext, + ESqlSrvStmtBindNext; + - "L2" - tracing level 2. All IPC calls traced; + - "S0" - [default] SQL statement tracing is off; + - "S1" - SQL statement tracing is on; + Example: + RSqlDatabase db; + //initialize the db object.... + ... + TSqlResourceProfiler profiler(db); + ..... + _LIT8(KConfig, ""); + profiler.Start(TSqlResourceProfiler::ESqlCounterTrace, &KConfig);//Start the profiling + ..... + profiler.Stop(TSqlResourceProfiler::ESqlCounterTrace); + The format of the traces is: + - SQL statement trace: + ¬¬SQL¬Prepare/Exec¬ + - "Database create" trace: + ¬¬CRE¬ + - "Database open" trace: + ¬¬OPN¬ + - "Database close" trace: + ¬¬CSE + - "IPC call error" trace: + ¬¬ERR¬¬¬err= + - "IPC call level 1 or level 2" trace: + ¬¬IPC¬¬¬¬¬¬..¬rc= + This service can be used only if the SQL code is compiled with the _SQLPROFILER macro. +@endcode + +@internalComponent +*/ +class TSqlResourceProfiler + { +public: + enum TSqlCounter + { + ESqlCounterFileIO, + ESqlCounterOsCall, + ESqlCounterOsCallTime, + ESqlCounterOsCallDetails, + ESqlCounterIpc, + ESqlCounterMemory, + ESqlCounterMaxAlloc, + ESqlCounterConfig, + ESqlCounterTrace + }; + IMPORT_C TSqlResourceProfiler(RSqlDatabase& aDatabase); + IMPORT_C TInt Start(TSqlCounter aCounterType, const TDesC8* aParam = NULL); + IMPORT_C TInt Stop(TSqlCounter aCounterType); + IMPORT_C TInt Reset(TSqlCounter aCounterType); + IMPORT_C TInt Query(TSqlCounter aCounterType, TDes8& aResult); + +private: + RSqlDatabase iDatabase; + + }; + +#endif //__SQLRESOURCEPROFILER_H__