persistentstorage/sql/SRC/Server/SqlSrvResourceProfiler.cpp
branchRCL_3
changeset 14 04ec7606545c
parent 11 211563e4b919
child 15 fcc16690f446
equal deleted inserted replaced
12:6b6fd149daa2 14:04ec7606545c
   660         {
   660         {
   661         prevTimeDiff = timeDiff;
   661         prevTimeDiff = timeDiff;
   662         TTime time;
   662         TTime time;
   663         time.UniversalTime();
   663         time.UniversalTime();
   664         TDateTime dt = time.DateTime();
   664         TDateTime dt = time.DateTime();
   665         TheSqlSrvProfileTraceBuf8.Format(_L8("% 8X¬%012ld¬TME¬%02d:%02d:%02d:%06d¬Prep8=%08d¬Prep16=%08d¬Ex8=%08d¬Ex16=%08d"),
   665         TheSqlSrvProfileTraceBuf8.Format(_L8("[SQL]¬%X¬%ld¬TME¬%02d:%02d:%02d:%06d¬Prep8¬%d¬Prep16¬%d¬Ex8¬%d¬Ex16¬%d"),
   666                 0, timeDiff, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond(),
   666                 0, timeDiff, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond(),
   667                 TheSqlSrvProfilerPreparedCnt8, TheSqlSrvProfilerPreparedCnt16, 
   667                 TheSqlSrvProfilerPreparedCnt8, TheSqlSrvProfilerPreparedCnt16, 
   668                 TheSqlSrvProfilerExecutedCnt8, TheSqlSrvProfilerExecutedCnt16);
   668                 TheSqlSrvProfilerExecutedCnt8, TheSqlSrvProfilerExecutedCnt16);
   669         if(TheSqlSrvProfilerTraceToFile)
   669         if(TheSqlSrvProfilerTraceToFile)
   670             {
   670             {
   756             ttlExecTime = aIpcTraceData[ipcCallIdx].iExecutionTime;
   756             ttlExecTime = aIpcTraceData[ipcCallIdx].iExecutionTime;
   757             count = ++aIpcTraceData[ipcCallIdx].iCount;
   757             count = ++aIpcTraceData[ipcCallIdx].iCount;
   758             }
   758             }
   759         if(ipcCallIdx >= 0  || (ipcCallIdx == KErrNotFound && TheSqlSrvProfilerTraceLevel == 2))
   759         if(ipcCallIdx >= 0  || (ipcCallIdx == KErrNotFound && TheSqlSrvProfilerTraceLevel == 2))
   760             {
   760             {
   761             TheSqlSrvProfileTraceBuf.Format(_L("% 8X¬%012ld¬IPC¬%08u¬%20.20S¬%012ld¬%010d¬%08d¬%04d¬%04d¬%04d¬%04d¬rc=%d"),  
   761             TheSqlSrvProfileTraceBuf.Format(_L("[SQL]¬%X¬%ld¬IPC¬%u¬%S¬%ld¬%d¬%d¬%d¬%d¬%d¬%d¬rc¬%d"),  
   762                     aDbHandle, 
   762                     aDbHandle, 
   763                     timeFromStart,
   763                     timeFromStart,
   764                     aIpcCounter,
   764                     aIpcCounter,
   765                     &ipcCallName, 
   765                     &ipcCallName, 
   766                     ttlExecTime, 
   766                     ttlExecTime, 
   786             return;
   786             return;
   787             }
   787             }
   788         TPtrC ipcCallName;
   788         TPtrC ipcCallName;
   789         (void)SqlIpcTraceIdxAndName(aFuncCode, ipcCallName); 
   789         (void)SqlIpcTraceIdxAndName(aFuncCode, ipcCallName); 
   790         TInt64 timeFromStart = SqlTimeFromStartUs();
   790         TInt64 timeFromStart = SqlTimeFromStartUs();
   791         TheSqlSrvProfileTraceBuf.Format(_L("% 8X¬%012ld¬ERR¬%08u¬%20.20S¬err=%d"), 
   791         TheSqlSrvProfileTraceBuf.Format(_L("[SQL]¬%X¬%ld¬ERR¬%u¬%S¬err¬%d"), 
   792                 aDbHandle, 
   792                 aDbHandle, 
   793                 timeFromStart,
   793                 timeFromStart,
   794                 aIpcCounter,
   794                 aIpcCounter,
   795                 &ipcCallName,
   795                 &ipcCallName,
   796                 aError);
   796                 aError);
   821         _LIT(KPrepare,  "Prepare16");
   821         _LIT(KPrepare,  "Prepare16");
   822         _LIT(KExec,     "Exec16");
   822         _LIT(KExec,     "Exec16");
   823         _LIT(KEmptyStr,  "");
   823         _LIT(KEmptyStr,  "");
   824         if(pos == 0)
   824         if(pos == 0)
   825             {
   825             {
   826             line.Format(_L("% 8X¬%012ld¬SQL¬%12.12S¬"), aDbHandle, timeFromStart, aPrepare ? &KPrepare : &KExec);
   826             line.Format(_L("[SQL]¬%X¬%ld¬SQL¬%S¬"), aDbHandle, timeFromStart, aPrepare ? &KPrepare : &KExec);
   827             }
   827             }
   828         else
   828         else
   829             {
   829             {
   830             if(!TheSqlSrvProfilerTraceToFile)
   830             if(!TheSqlSrvProfilerTraceToFile)
   831                 {
   831                 {
   832                 line.Format(_L("% 8X¬%012ld¬SQL¬%12.12S¬"), aDbHandle, timeFromStart, &KEmptyStr);
   832                 line.Format(_L("[SQL]¬%X¬%ld¬SQL¬%S¬"), aDbHandle, timeFromStart, &KEmptyStr);
   833                 }
   833                 }
   834             }
   834             }
   835         TInt l = Min(len, (line.MaxLength() - line.Length()));
   835         TInt l = Min(len, (line.MaxLength() - line.Length()));
   836         TPtrC ptr(aSql.Ptr() + pos, l);
   836         TPtrC ptr(aSql.Ptr() + pos, l);
   837         pos += l;
   837         pos += l;
   866         _LIT(KPrepare,   "Prepare8");
   866         _LIT(KPrepare,   "Prepare8");
   867         _LIT(KExec,      "Exec8");
   867         _LIT(KExec,      "Exec8");
   868         _LIT(KEmptyStr,  "");
   868         _LIT(KEmptyStr,  "");
   869         if(pos == 0)
   869         if(pos == 0)
   870             {
   870             {
   871             line.Format(_L("% 8X¬%012ld¬SQL¬%12.12S¬"), aDbHandle, timeFromStart, aPrepare ? &KPrepare : &KExec);
   871             line.Format(_L("[SQL]¬%X¬%ld¬SQL¬%S¬"), aDbHandle, timeFromStart, aPrepare ? &KPrepare : &KExec);
   872             }
   872             }
   873         else
   873         else
   874             {
   874             {
   875             if(!TheSqlSrvProfilerTraceToFile)
   875             if(!TheSqlSrvProfilerTraceToFile)
   876                 {
   876                 {
   877                 line.Format(_L("% 8X¬%012ld¬SQL¬%12.12S¬"), aDbHandle, timeFromStart, &KEmptyStr);
   877                 line.Format(_L("[SQL]¬%X¬%ld¬SQL¬%S¬"), aDbHandle, timeFromStart, &KEmptyStr);
   878                 }
   878                 }
   879             }
   879             }
   880         TInt l = Min(len, (line.MaxLength() - line.Length()));
   880         TInt l = Min(len, (line.MaxLength() - line.Length()));
   881         TPtrC8 ptr(aSql.Ptr() + pos, l);
   881         TPtrC8 ptr(aSql.Ptr() + pos, l);
   882         pos += l;
   882         pos += l;
   902         if(KSqlSrvProfilerDbName().Length() > 0 &&  (aDbHandle == 0 || TheSqlSrvProfilerHandle != aDbHandle))
   902         if(KSqlSrvProfilerDbName().Length() > 0 &&  (aDbHandle == 0 || TheSqlSrvProfilerHandle != aDbHandle))
   903             {
   903             {
   904             return;
   904             return;
   905             }
   905             }
   906         TInt64 timeFromStart = SqlTimeFromStartUs();
   906         TInt64 timeFromStart = SqlTimeFromStartUs();
   907         TheSqlSrvProfileTraceBuf.Format(_L("% 08X¬%012ld¬CRE¬%S"), 
   907         TheSqlSrvProfileTraceBuf.Format(_L("[SQL]¬%X¬%ld¬CRE¬%S"), 
   908                 aDbHandle, 
   908                 aDbHandle, 
   909                 timeFromStart,
   909                 timeFromStart,
   910                 &aDbName);
   910                 &aDbName);
   911         SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace);
   911         SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace);
   912         }
   912         }
   924         if(KSqlSrvProfilerDbName().Length() > 0 &&  (aDbHandle == 0 || TheSqlSrvProfilerHandle != aDbHandle))
   924         if(KSqlSrvProfilerDbName().Length() > 0 &&  (aDbHandle == 0 || TheSqlSrvProfilerHandle != aDbHandle))
   925             {
   925             {
   926             return;
   926             return;
   927             }
   927             }
   928         TInt64 timeFromStart = SqlTimeFromStartUs();
   928         TInt64 timeFromStart = SqlTimeFromStartUs();
   929         TheSqlSrvProfileTraceBuf.Format(_L("% 8X¬%012ld¬OPN¬%S"), 
   929         TheSqlSrvProfileTraceBuf.Format(_L("[SQL]¬%X¬%ld¬OPN¬%S"), 
   930                 aDbHandle, 
   930                 aDbHandle, 
   931                 timeFromStart,
   931                 timeFromStart,
   932                 &aDbName);
   932                 &aDbName);
   933         SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace);
   933         SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace);
   934         }
   934         }
   942         if(KSqlSrvProfilerDbName().Length() > 0 &&  (aDbHandle == 0 || TheSqlSrvProfilerHandle != aDbHandle))
   942         if(KSqlSrvProfilerDbName().Length() > 0 &&  (aDbHandle == 0 || TheSqlSrvProfilerHandle != aDbHandle))
   943             {
   943             {
   944             return;
   944             return;
   945             }
   945             }
   946         TInt64 timeFromStart = SqlTimeFromStartUs();
   946         TInt64 timeFromStart = SqlTimeFromStartUs();
   947         TheSqlSrvProfileTraceBuf.Format(_L("% 8X¬%012ld¬CSE"),  
   947         TheSqlSrvProfileTraceBuf.Format(_L("[SQL]¬%X¬%ld¬CSE"),  
   948                 aDbHandle, 
   948                 aDbHandle, 
   949                 timeFromStart);
   949                 timeFromStart);
   950         SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace);
   950         SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace);
   951         if(aDbHandle == TheSqlSrvProfilerHandle)
   951         if(aDbHandle == TheSqlSrvProfilerHandle)
   952             {
   952             {
   984             TheSqlSrvTraceFs.Close();
   984             TheSqlSrvTraceFs.Close();
   985             TheSqlSrvProfilerTraceToFile = EFalse;
   985             TheSqlSrvProfilerTraceToFile = EFalse;
   986             RDebug::Print(_L("SQL trace file creation failed with err=%d"), err);
   986             RDebug::Print(_L("SQL trace file creation failed with err=%d"), err);
   987             }
   987             }
   988         }
   988         }
   989     TheSqlSrvProfileTraceBuf.Format(_L("% 8X¬%012ld¬SRV¬START"), 0, timeFromStart); 
   989     TheSqlSrvProfileTraceBuf.Format(_L("[SQL]¬%X¬%ld¬SRV¬START"), 0, timeFromStart); 
   990     SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace);
   990     SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace);
   991     }
   991     }
   992 
   992 
   993 //Prints a trace when the SQL server stops
   993 //Prints a trace when the SQL server stops
   994 void SqlPrintServerStop()
   994 void SqlPrintServerStop()
   995     {
   995     {
   996     TInt64 timeFromStart = SqlTimeFromStartUs();
   996     TInt64 timeFromStart = SqlTimeFromStartUs();
   997     TheSqlSrvProfileTraceBuf.Format(_L("% 8X¬%012ld¬SRV¬STOP"), 0, timeFromStart); 
   997     TheSqlSrvProfileTraceBuf.Format(_L("[SQL]¬%X¬%ld¬SRV¬STOP"), 0, timeFromStart); 
   998     SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace);
   998     SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace);
   999     if(TheSqlSrvProfilerTraceToFile)
   999     if(TheSqlSrvProfilerTraceToFile)
  1000         {
  1000         {
  1001         TheTheSqlSrvTraceFile.Close();
  1001         TheTheSqlSrvTraceFile.Close();
  1002         TheSqlSrvTraceFs.Close();
  1002         TheSqlSrvTraceFs.Close();