persistentstorage/sqlite3api/TEST/t_sqliteperf.cpp
changeset 0 08ec8eefde2f
child 23 26645d81f48d
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     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 #include <e32test.h>
       
    17 #include <bautils.h>
       
    18 #include <e32math.h>
       
    19 #include <hal.h>
       
    20 #include <sqldb.h>
       
    21 #include "t_sqliteperf.h"
       
    22 
       
    23 ///////////////////////////////////////////////////////////////////////////////////////
       
    24 
       
    25 static RTest TheTest(_L("t_sqliteperf test"));
       
    26 _LIT(KTestDir, "c:\\test\\");
       
    27 _LIT(KTestDbName,   "c:\\test\\t_sqliteperf.db");
       
    28 _LIT8(KTestDbName8, "c:\\test\\t_sqliteperf.db\x0");
       
    29 
       
    30 _LIT(KSqlSrvName, "sqlsrv.exe");
       
    31 
       
    32 static RSqlDatabase TheDb;
       
    33 
       
    34 const TInt KInsertRecCnt = 1000;
       
    35 const TInt KUpdateRecCnt = KInsertRecCnt / 10;
       
    36 const TInt KDeleteRecCnt = KInsertRecCnt / 10;
       
    37 const TInt KSelectRecCnt = KInsertRecCnt / 10;
       
    38 
       
    39 static TInt TheUpdateRecIds[KUpdateRecCnt] = {0};
       
    40 static TInt TheDeleteRecIds[KDeleteRecCnt] = {0};
       
    41 static TInt TheSelectRecIds[KSelectRecCnt] = {0};
       
    42 
       
    43 static TInt TheInsertRecId = 0;
       
    44 static TInt TheUpdateRecId = 0;
       
    45 static TInt TheDeleteRecId = 0;
       
    46 static TInt TheSelectRecId = 0;
       
    47 
       
    48 const char KMultiInsertSql[] = "INSERT INTO Tbl VALUES(:Id, 9234567890, 99.998, 'TEXT VALUE', x'AABBCCDDEEFF')";
       
    49 const char KMultiUpdateSql[] = "UPDATE Tbl SET D=11.113 WHERE I IN";
       
    50 const char KMultiDeleteSql[] = "DELETE FROM Tbl WHERE I IN";
       
    51 const char KMultiSelectSql[] = "SELECT I64,D,T,B FROM Tbl WHERE I IN";
       
    52 
       
    53 const char KSingleInsertSql[] = "INSERT INTO Tbl VALUES(%d, 9234567890, 99.998, 'TEXT VALUE', x'AABBCCDDEEFF')";
       
    54 const char KSingleUpdateSql[] = "UPDATE Tbl SET D=11.113 WHERE I=";
       
    55 const char KSingleDeleteSql[] = "DELETE FROM Tbl WHERE I=";
       
    56 const char KSingleSelectSql[] = "SELECT I64,D,T,B FROM Tbl WHERE I=";
       
    57 
       
    58 //This buffer is used for SQL statement formatting. 2000 bytes should be enough as a buffer max length.
       
    59 static TBuf8<2000> TheSqlBuf;
       
    60 //This buffer is used for printf related formatting. 500 characters should be enough.
       
    61 static TBuf<500> ThePrintBuf;
       
    62 
       
    63 #define UNUSED_VAR(a) (a) = (a)
       
    64 #define UNUSED_PTR(a) a.Set(a)
       
    65 
       
    66 ///////////////////////////////////////////////////////////////////////////////////////
       
    67 
       
    68 extern "C" void TestAbort(TInt aLine)
       
    69 	{
       
    70 	TheTest(0, aLine);
       
    71 	}
       
    72 
       
    73 extern "C" const char* TestDbName(void)
       
    74 	{
       
    75 	return (const char*)KTestDbName8().Ptr();
       
    76 	}
       
    77 
       
    78 extern "C" void PrintS(const char* aFmt, const char* aMsg)
       
    79 	{
       
    80 	TheSqlBuf.Format(TPtrC8((const TUint8*)aFmt), aMsg);
       
    81 	ThePrintBuf.Copy(TheSqlBuf);
       
    82 	TheTest.Printf(ThePrintBuf);
       
    83 	}
       
    84 
       
    85 extern "C" void PrintI(const char* aFmt, int a1)
       
    86 	{
       
    87 	TheSqlBuf.Format(TPtrC8((const TUint8*)aFmt), a1);
       
    88 	ThePrintBuf.Copy(TheSqlBuf);
       
    89 	TheTest.Printf(ThePrintBuf);
       
    90 	}
       
    91 
       
    92 extern "C" void PrintIII(const char* aFmt, int a1, int a2, int a3)
       
    93 	{
       
    94 	TheSqlBuf.Format(TPtrC8((const TUint8*)aFmt), a1, a2, a3);
       
    95 	ThePrintBuf.Copy(TheSqlBuf);
       
    96 	TheTest.Printf(ThePrintBuf);
       
    97 	}
       
    98 
       
    99 static void DeleteTestFiles()
       
   100 	{
       
   101 	TheDb.Close();
       
   102 	(void)RSqlDatabase::Delete(KTestDbName);
       
   103 	}
       
   104 
       
   105 ///////////////////////////////////////////////////////////////////////////////////////
       
   106 //Test macros and functions
       
   107 static void Check(TInt aValue, TInt aLine)
       
   108 	{
       
   109 	if(!aValue)
       
   110 		{
       
   111 		DeleteTestFiles();
       
   112 		TheTest(EFalse, aLine);
       
   113 		}
       
   114 	}
       
   115 static void Check(TInt aValue, TInt aExpected, TInt aLine)
       
   116 	{
       
   117 	if(aValue != aExpected)
       
   118 		{
       
   119 		DeleteTestFiles();
       
   120 		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
       
   121 		TheTest(EFalse, aLine);
       
   122 		}
       
   123 	}
       
   124 #define TEST(arg) ::Check((arg), __LINE__)
       
   125 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
       
   126 
       
   127 ///////////////////////////////////////////////////////////////////////////////////////
       
   128 
       
   129 static TInt KillProcess(const TDesC& aProcessName)
       
   130 	{
       
   131 	TFullName name;
       
   132 	//RDebug::Print(_L("Find and kill \"%S\" process.\n"), &aProcessName);
       
   133 	TBuf<64> pattern(aProcessName);
       
   134 	TInt length = pattern.Length();
       
   135 	pattern += _L("*");
       
   136 	TFindProcess procFinder(pattern);
       
   137 
       
   138 	while (procFinder.Next(name) == KErrNone)
       
   139 		{
       
   140 		if (name.Length() > length)
       
   141 			{//If found name is a string containing aProcessName string.
       
   142 			TChar c(name[length]);
       
   143 			if (c.IsAlphaDigit() ||
       
   144 				c == TChar('_') ||
       
   145 				c == TChar('-'))
       
   146 				{
       
   147 				// If the found name is other valid application name
       
   148 				// starting with aProcessName string.
       
   149 				//RDebug::Print(_L(":: Process name: \"%S\".\n"), &name);
       
   150 				continue;
       
   151 				}
       
   152 			}
       
   153 		RProcess proc;
       
   154 		if (proc.Open(name) == KErrNone)
       
   155 			{
       
   156 			proc.Kill(0);
       
   157 			//RDebug::Print(_L("\"%S\" process killed.\n"), &name);
       
   158 			}
       
   159 		proc.Close();
       
   160 		}
       
   161 	return KErrNone;
       
   162 	}
       
   163 
       
   164 static TInt TheCounterFreq = -10000000;
       
   165 const TInt KMicroSecIn1Sec = 1000000;
       
   166 
       
   167 //Prints aFastCount parameter (converted to us)
       
   168 static TInt FcDiff2Us(TUint32 aFastCount)
       
   169 	{
       
   170 	double v = ((double)aFastCount * KMicroSecIn1Sec) / (double)TheCounterFreq;
       
   171 	TInt v2 = (TInt)v;
       
   172 	return v2;
       
   173 	}
       
   174 
       
   175 static void GetFastCounterFrequency()
       
   176 	{
       
   177 	TEST2(HAL::Get(HAL::EFastCounterFrequency, TheCounterFreq), KErrNone);
       
   178 	TheTest.Printf(_L("Counter frequency=%d\r\n"), TheCounterFreq);
       
   179 	}
       
   180 
       
   181 extern "C" unsigned int FastCounterValue(void)
       
   182 	{
       
   183 	return User::FastCounter();
       
   184 	}
       
   185 
       
   186 //The performance test case results are stored in the ThePerfTestResult array.
       
   187 static TUint32 ThePerfTestResult[EPerfTestModeCnt][EPerfTestTypeCnt];
       
   188 
       
   189 extern "C" void StorePerfTestResult(TPerfTestMode aMode, TPerfTestType aType, unsigned int aResult)
       
   190 	{
       
   191 	ThePerfTestResult[aMode][aType] = aResult;
       
   192 	}
       
   193 
       
   194 static void PrintPerfTestResults()
       
   195 	{
       
   196 	TInt r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode]          [EPerfTestMultiInsert]);
       
   197 	TInt r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode]    [EPerfTestMultiInsert]);
       
   198 	TInt r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestMultiInsert]);
       
   199 	TInt r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
       
   200 	TInt r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
       
   201 	TheTest.Printf(_L("###                 SQL            SQLITE-SQL     SQLITE-DEFAULT\r\n"));
       
   202 	TheTest.Printf(_L("###Mutli Insert:  %8dus     %8dus     %8dus   %8d%%   %8d%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
       
   203 
       
   204 	r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode]          [EPerfTestMultiUpdate]);
       
   205 	r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode]    [EPerfTestMultiUpdate]);
       
   206 	r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestMultiUpdate]);
       
   207 	r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
       
   208 	r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
       
   209 	TheTest.Printf(_L("###Mutli Update:  %8dus     %8dus     %8dus   %8d%%   %8d%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
       
   210 
       
   211 	r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode]          [EPerfTestMultiDelete]);
       
   212 	r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode]    [EPerfTestMultiDelete]);
       
   213 	r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestMultiDelete]);
       
   214 	r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
       
   215 	r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
       
   216 	TheTest.Printf(_L("###Mutli Delete:  %8dus     %8dus     %8dus   %8d%%   %8d%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
       
   217 
       
   218 	r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode]          [EPerfTestMultiSelect]);
       
   219 	r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode]    [EPerfTestMultiSelect]);
       
   220 	r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestMultiSelect]);
       
   221 	r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
       
   222 	r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
       
   223 	TheTest.Printf(_L("###Mutli Select:  %8dus     %8dus     %8dus   %8d%%   %8d%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
       
   224 
       
   225 	r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode]          [EPerfTestSingleInsert]);
       
   226 	r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode]    [EPerfTestSingleInsert]);
       
   227 	r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestSingleInsert]);
       
   228 	r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
       
   229 	r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
       
   230 	TheTest.Printf(_L("##Single Insert:  %8dus     %8dus     %8dus   %8d%%   %8d%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
       
   231 
       
   232 	r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode]          [EPerfTestSingleUpdate]);
       
   233 	r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode]    [EPerfTestSingleUpdate]);
       
   234 	r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestSingleUpdate]);
       
   235 	r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
       
   236 	r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
       
   237 	TheTest.Printf(_L("##Single Update:  %8dus     %8dus     %8dus   %8d%%   %8d%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
       
   238 
       
   239 	r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode]          [EPerfTestSingleDelete]);
       
   240 	r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode]    [EPerfTestSingleDelete]);
       
   241 	r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestSingleDelete]);
       
   242 	r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
       
   243 	r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
       
   244 	TheTest.Printf(_L("##Single Delete:  %8dus     %8dus     %8dus   %8d%%   %8d%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
       
   245 
       
   246 	r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode]          [EPerfTestSingleSelect]);
       
   247 	r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode]    [EPerfTestSingleSelect]);
       
   248 	r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestSingleSelect]);
       
   249 	r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
       
   250 	r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
       
   251 	TheTest.Printf(_L("##Single Select:  %8dus     %8dus     %8dus   %8d%%   %8d%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
       
   252 	}
       
   253 
       
   254 ///////////////////////////////////////////////////////////////////////////////////////
       
   255 
       
   256 static void CreateTestDir()
       
   257     {
       
   258     RFs fs;
       
   259 	TInt err = fs.Connect();
       
   260 	TEST2(err, KErrNone);
       
   261 
       
   262 	err = fs.MkDir(KTestDir);
       
   263 	TEST(err == KErrNone || err == KErrAlreadyExists);
       
   264 
       
   265 	err = fs.CreatePrivatePath(EDriveC);
       
   266 	TEST(err == KErrNone || err == KErrAlreadyExists);
       
   267 
       
   268 	fs.Close();
       
   269 	}
       
   270 
       
   271 ///////////////////////////////////////////////////////////////////////////////////////
       
   272 
       
   273 static void CreateTestDatabase()
       
   274 	{
       
   275 	RSqlDatabase::Delete(KTestDbName);
       
   276 
       
   277 	_LIT8(KConfigStr, "encoding=\"UTF-8\"");
       
   278 	TInt err = TheDb.Create(KTestDbName, &KConfigStr);
       
   279 	TEST2(err, KErrNone);
       
   280 
       
   281 	err = TheDb.Exec(_L8("CREATE TABLE Tbl(I INTEGER PRIMARY KEY, I64 BIGINT, D DOUBLE, T TEXT, B BINARY)"));
       
   282 	TEST2(err, 1);
       
   283 
       
   284 	TheDb.Close();
       
   285 	}
       
   286 
       
   287 ///////////////////////////////////////////////////////////////////////////////////////
       
   288 ////////////////////             SQL server tests           ///////////////////////////
       
   289 ///////////////////////////////////////////////////////////////////////////////////////
       
   290 
       
   291 /**
       
   292 @SYMTestCaseID			SYSLIB-SQLITE3-UT-4010
       
   293 @SYMTestCaseDesc		SQL server multi-insert performance test.
       
   294 						The test inserts 1000 records in a single transaction and stores
       
   295 						the execution time for later use (comparison and printing).
       
   296 @SYMTestPriority		High
       
   297 @SYMTestActions			SQL server multi-insert performance test.
       
   298 @SYMTestExpectedResults Test must not fail
       
   299 @SYMREQ					REQ8782
       
   300 */
       
   301 static void SqlServerMultiInsertTest(const char aInsertSql[], TInt aInsertRecCnt)
       
   302 	{
       
   303 	TheTest.Next( _L(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4010 "));
       
   304 	(void)KillProcess(KSqlSrvName);
       
   305 
       
   306 	TInt err = TheDb.Open(KTestDbName);
       
   307 	TEST2(err, KErrNone);
       
   308 
       
   309 	RSqlStatement stmt;
       
   310 	err = stmt.Prepare(TheDb, TPtrC8((const TUint8*)aInsertSql));
       
   311 	TEST2(err, KErrNone);
       
   312 
       
   313 	TUint32 fc = FastCounterValue();
       
   314 	err = TheDb.Exec(_L8("BEGIN"));
       
   315 	TEST(err >= 0);
       
   316 
       
   317 	for(TInt i=0;i<aInsertRecCnt;++i)
       
   318 		{
       
   319 		err = stmt.BindInt(0, i + 1);
       
   320 		TEST2(err, KErrNone);
       
   321 		err = stmt.Exec();
       
   322 		TEST2(err, 1);
       
   323 		err = stmt.Reset();
       
   324 		TEST2(err, KErrNone);
       
   325 		}
       
   326 
       
   327 	err = TheDb.Exec(_L8("COMMIT"));
       
   328 	TEST(err >= 0);
       
   329 	StorePerfTestResult(EPerfTestSqlMode, EPerfTestMultiInsert, FastCounterValue() - fc);
       
   330 
       
   331 	stmt.Close();
       
   332 	TheDb.Close();
       
   333 	}
       
   334 
       
   335 static void FormatSqlStmt(TDes8& aSqlBuf, const char aSql[], TInt aRecIds[], TInt aRecCnt)
       
   336 	{
       
   337 	aSqlBuf.Copy(TPtrC8((const TUint8*)aSql));
       
   338 	aSqlBuf.Append(_L8("("));
       
   339 	for(TInt i=0;i<aRecCnt;++i)
       
   340 		{
       
   341 		aSqlBuf.AppendNum((TInt64)aRecIds[i]);
       
   342 		aSqlBuf.Append(_L8(","));
       
   343 		}
       
   344 	aSqlBuf.SetLength(aSqlBuf.Length() - 1);
       
   345 	aSqlBuf.Append(_L8(")"));
       
   346 	}
       
   347 
       
   348 /**
       
   349 @SYMTestCaseID			SYSLIB-SQLITE3-UT-4011
       
   350 @SYMTestCaseDesc		SQL server multi-update performance test.
       
   351 						The test updates 100 randomly chosen records and stores
       
   352 						the execution time for later use (comparison and printing).
       
   353 @SYMTestPriority		High
       
   354 @SYMTestActions			SQL server multi-update performance test.
       
   355 @SYMTestExpectedResults Test must not fail
       
   356 @SYMREQ					REQ8782
       
   357 */
       
   358 static void SqlServerMultiUpdateTest(const char aUpdateSql[], TInt aUpdateRecIds[], TInt aUpdateRecCnt)
       
   359 	{
       
   360     TheTest.Next( _L(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4011 "));
       
   361 	(void)KillProcess(KSqlSrvName);
       
   362 
       
   363 	TInt err = TheDb.Open(KTestDbName);
       
   364 	TEST2(err, KErrNone);
       
   365 
       
   366 	FormatSqlStmt(TheSqlBuf, aUpdateSql, aUpdateRecIds, aUpdateRecCnt);
       
   367 
       
   368 	TUint32 fc = FastCounterValue();
       
   369 	err = TheDb.Exec(TheSqlBuf);
       
   370 	StorePerfTestResult(EPerfTestSqlMode, EPerfTestMultiUpdate, FastCounterValue() - fc);
       
   371 	TEST2(err, aUpdateRecCnt);
       
   372 
       
   373 	TheDb.Close();
       
   374 	}
       
   375 
       
   376 /**
       
   377 @SYMTestCaseID			SYSLIB-SQLITE3-UT-4012
       
   378 @SYMTestCaseDesc		SQL server multi-delete performance test.
       
   379 						The test deletes 100 randomly chosen records and stores
       
   380 						the execution time for later use (comparison and printing).
       
   381 @SYMTestPriority		High
       
   382 @SYMTestActions			SQL server multi-delete performance test.
       
   383 @SYMTestExpectedResults Test must not fail
       
   384 @SYMREQ					REQ8782
       
   385 */
       
   386 static void SqlServerMultiDeleteTest(const char aDeleteSql[], TInt aDeleteRecIds[], TInt aDeleteRecCnt)
       
   387 	{
       
   388 	TheTest.Next( _L(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4012 "));
       
   389 	(void)KillProcess(KSqlSrvName);
       
   390 
       
   391 	TInt err = TheDb.Open(KTestDbName);
       
   392 	TEST2(err, KErrNone);
       
   393 
       
   394 	FormatSqlStmt(TheSqlBuf, aDeleteSql, aDeleteRecIds, aDeleteRecCnt);
       
   395 
       
   396 	TUint32 fc = FastCounterValue();
       
   397 	err = TheDb.Exec(TheSqlBuf);
       
   398 	StorePerfTestResult(EPerfTestSqlMode, EPerfTestMultiDelete, FastCounterValue() - fc);
       
   399 	TEST2(err, aDeleteRecCnt);
       
   400 
       
   401 	TheDb.Close();
       
   402 	}
       
   403 
       
   404 /**
       
   405 @SYMTestCaseID			SYSLIB-SQLITE3-UT-4013
       
   406 @SYMTestCaseDesc		SQL server multi-select performance test.
       
   407 						The test selects 100 randomly chosen records and stores
       
   408 						the execution time for later use (comparison and printing).
       
   409 @SYMTestPriority		High
       
   410 @SYMTestActions			SQL server multi-select performance test.
       
   411 @SYMTestExpectedResults Test must not fail
       
   412 @SYMREQ					REQ8782
       
   413 */
       
   414 static void SqlServerMultiSelectTest(const char aSelectSql[], TInt aSelectRecIds[], TInt aSelectRecCnt)
       
   415 	{
       
   416 	TheTest.Next( _L(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4013 "));
       
   417 	(void)KillProcess(KSqlSrvName);
       
   418 
       
   419 	TInt err = TheDb.Open(KTestDbName);
       
   420 	TEST2(err, KErrNone);
       
   421 
       
   422 	FormatSqlStmt(TheSqlBuf, aSelectSql, aSelectRecIds, aSelectRecCnt);
       
   423 
       
   424 	RSqlStatement stmt;
       
   425 	err = stmt.Prepare(TheDb, TheSqlBuf);
       
   426 	TEST2(err, KErrNone);
       
   427 	TInt recCnt = 0;
       
   428 	TUint32 fc = FastCounterValue();
       
   429 	while((err = stmt.Next()) == KSqlAtRow)
       
   430 		{
       
   431 		TInt64 i64 = stmt.ColumnInt64(0);
       
   432 		UNUSED_VAR(i64);
       
   433 		TReal d = stmt.ColumnReal(1);
       
   434 		UNUSED_VAR(d);
       
   435 		TPtrC t;
       
   436 		err = stmt.ColumnText(2, t);
       
   437 		TEST2(err, KErrNone);
       
   438 		UNUSED_PTR(t);
       
   439 		TPtrC8 b;
       
   440 		err = stmt.ColumnBinary(3, b);
       
   441 		TEST2(err, KErrNone);
       
   442 		UNUSED_PTR(b);
       
   443 		++recCnt;
       
   444 		}
       
   445 	StorePerfTestResult(EPerfTestSqlMode, EPerfTestMultiSelect, FastCounterValue() - fc);
       
   446 	TEST2(err, KSqlAtEnd);
       
   447 	TEST2(recCnt, aSelectRecCnt);
       
   448 
       
   449 	stmt.Close();
       
   450 	TheDb.Close();
       
   451 	}
       
   452 
       
   453 /**
       
   454 @SYMTestCaseID			SYSLIB-SQLITE3-UT-4014
       
   455 @SYMTestCaseDesc		SQL server single-insert performance test.
       
   456 						The test inserts one record and stores
       
   457 						the execution time for later use (comparison and printing).
       
   458 @SYMTestPriority		High
       
   459 @SYMTestActions			SQL server single-insert performance test.
       
   460 @SYMTestExpectedResults Test must not fail
       
   461 @SYMREQ					REQ8782
       
   462 */
       
   463 static void SqlServerSingleInsertTest(const char aSingleInsertSql[], TInt aInsertRecId)
       
   464 	{
       
   465 	TheTest.Next( _L(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4014 "));
       
   466 	(void)KillProcess(KSqlSrvName);
       
   467 
       
   468 	TInt err = TheDb.Open(KTestDbName);
       
   469 	TEST2(err, KErrNone);
       
   470 
       
   471 	TheSqlBuf.Format(TPtrC8((const TUint8*)aSingleInsertSql), aInsertRecId);
       
   472 	TUint32 fc = FastCounterValue();
       
   473 	err = TheDb.Exec(TheSqlBuf);
       
   474 	StorePerfTestResult(EPerfTestSqlMode, EPerfTestSingleInsert, FastCounterValue() - fc);
       
   475 	TEST2(err, 1);
       
   476 
       
   477 	TheDb.Close();
       
   478 	}
       
   479 
       
   480 /**
       
   481 @SYMTestCaseID			SYSLIB-SQLITE3-UT-4015
       
   482 @SYMTestCaseDesc		SQL server single-update performance test.
       
   483 						The test updates one randomly chosen record and stores
       
   484 						the execution time for later use (comparison and printing).
       
   485 @SYMTestPriority		High
       
   486 @SYMTestActions			SQL server single-update performance test.
       
   487 @SYMTestExpectedResults Test must not fail
       
   488 @SYMREQ					REQ8782
       
   489 */
       
   490 static void SqlServerSingleUpdateTest(const char aSingleUpdateSql[], TInt aUpdateRecId)
       
   491 	{
       
   492 	TheTest.Next( _L(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4015 "));
       
   493 	(void)KillProcess(KSqlSrvName);
       
   494 
       
   495 	TInt err = TheDb.Open(KTestDbName);
       
   496 	TEST2(err, KErrNone);
       
   497 
       
   498 	TheSqlBuf.Copy(TPtrC8((const TUint8*)aSingleUpdateSql));
       
   499 	TheSqlBuf.AppendNum((TInt64)aUpdateRecId);
       
   500 	TUint32 fc = FastCounterValue();
       
   501 	err = TheDb.Exec(TheSqlBuf);
       
   502 	StorePerfTestResult(EPerfTestSqlMode, EPerfTestSingleUpdate, FastCounterValue() - fc);
       
   503 	TEST2(err, 1);
       
   504 
       
   505 	TheDb.Close();
       
   506 	}
       
   507 
       
   508 /**
       
   509 @SYMTestCaseID			SYSLIB-SQLITE3-UT-4016
       
   510 @SYMTestCaseDesc		SQL server single-delete performance test.
       
   511 						The test deletes one randomly chosen record and stores
       
   512 						the execution time for later use (comparison and printing).
       
   513 @SYMTestPriority		High
       
   514 @SYMTestActions			SQL server single-delete performance test.
       
   515 @SYMTestExpectedResults Test must not fail
       
   516 @SYMREQ					REQ8782
       
   517 */
       
   518 static void SqlServerSingleDeleteTest(const char aSingleDeleteSql[], TInt aDeleteRecId)
       
   519 	{
       
   520 	TheTest.Next( _L(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4016 "));
       
   521 	(void)KillProcess(KSqlSrvName);
       
   522 
       
   523 	TInt err = TheDb.Open(KTestDbName);
       
   524 	TEST2(err, KErrNone);
       
   525 
       
   526 	TheSqlBuf.Copy(TPtrC8((const TUint8*)aSingleDeleteSql));
       
   527 	TheSqlBuf.AppendNum((TInt64)aDeleteRecId);
       
   528 	TUint32 fc = FastCounterValue();
       
   529 	err = TheDb.Exec(TheSqlBuf);
       
   530 	StorePerfTestResult(EPerfTestSqlMode, EPerfTestSingleDelete, FastCounterValue() - fc);
       
   531 	TEST2(err, 1);
       
   532 
       
   533 	TheDb.Close();
       
   534 	}
       
   535 
       
   536 /**
       
   537 @SYMTestCaseID			SYSLIB-SQLITE3-UT-4017
       
   538 @SYMTestCaseDesc		SQL server single-select performance test.
       
   539 						The test selects one randomly chosen record and stores
       
   540 						the execution time for later use (comparison and printing).
       
   541 @SYMTestPriority		High
       
   542 @SYMTestActions			SQL server single-select performance test.
       
   543 @SYMTestExpectedResults Test must not fail
       
   544 @SYMREQ					REQ8782
       
   545 */
       
   546 static void SqlServerSingleSelectTest(const char aSingleSelectSql[], TInt aSelectRecId)
       
   547 	{
       
   548 	TheTest.Next( _L(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4017 "));
       
   549 	(void)KillProcess(KSqlSrvName);
       
   550 
       
   551 	TInt err = TheDb.Open(KTestDbName);
       
   552 	TEST2(err, KErrNone);
       
   553 
       
   554 	TheSqlBuf.Copy(TPtrC8((const TUint8*)aSingleSelectSql));
       
   555 	TheSqlBuf.AppendNum((TInt64)aSelectRecId);
       
   556 
       
   557 	RSqlStatement stmt;
       
   558 	err = stmt.Prepare(TheDb, TheSqlBuf);
       
   559 	TEST2(err, KErrNone);
       
   560 	TInt recCnt = 0;
       
   561 	TUint32 fc = FastCounterValue();
       
   562 	while((err = stmt.Next()) == KSqlAtRow)
       
   563 		{
       
   564 		TInt64 i64 = stmt.ColumnInt64(0);
       
   565 		UNUSED_VAR(i64);
       
   566 		TReal d = stmt.ColumnReal(1);
       
   567 		UNUSED_VAR(d);
       
   568 		TPtrC t;
       
   569 		err = stmt.ColumnText(2, t);
       
   570 		TEST2(err, KErrNone);
       
   571 		UNUSED_PTR(t);
       
   572 		TPtrC8 b;
       
   573 		err = stmt.ColumnBinary(3, b);
       
   574 		TEST2(err, KErrNone);
       
   575 		UNUSED_PTR(b);
       
   576 		++recCnt;
       
   577 		}
       
   578 	StorePerfTestResult(EPerfTestSqlMode, EPerfTestSingleSelect, FastCounterValue() - fc);
       
   579 	TEST2(err, KSqlAtEnd);
       
   580 	TEST2(recCnt, 1);
       
   581 
       
   582 	stmt.Close();
       
   583 	TheDb.Close();
       
   584 	}
       
   585 
       
   586 ///////////////////////////////////////////////////////////////////////////////////////
       
   587 ///////////////////////////////////////////////////////////////////////////////////////
       
   588 ///////////////////////////////////////////////////////////////////////////////////////
       
   589 
       
   590 static void DoSqlServerTests()
       
   591 	{
       
   592 	TheTest.Next(_L("SQL: Create the test database"));
       
   593 	CreateTestDatabase();
       
   594 
       
   595 	TBuf<100> msgbuf;
       
   596 
       
   597 	msgbuf.Format(_L("SQL: insert %d records in a single transaction"), KInsertRecCnt);
       
   598 	TheTest.Next(msgbuf);
       
   599 	SqlServerMultiInsertTest(KMultiInsertSql, KInsertRecCnt);
       
   600 
       
   601 	msgbuf.Format(_L("SQL: update %d records in a single transaction"), KUpdateRecCnt);
       
   602 	TheTest.Next(msgbuf);
       
   603 	SqlServerMultiUpdateTest(KMultiUpdateSql, TheUpdateRecIds, KUpdateRecCnt);
       
   604 
       
   605 	msgbuf.Format(_L("SQL: delete %d records in a single transaction"), KDeleteRecCnt);
       
   606 	TheTest.Next(msgbuf);
       
   607 	SqlServerMultiDeleteTest(KMultiDeleteSql, TheDeleteRecIds, KDeleteRecCnt);
       
   608 
       
   609 	msgbuf.Format(_L("SQL: select %d records"), KSelectRecCnt);
       
   610 	TheTest.Next(msgbuf);
       
   611 	SqlServerMultiSelectTest(KMultiSelectSql, TheSelectRecIds, KSelectRecCnt);
       
   612 
       
   613 	TheTest.Next(_L("SQL: insert a single record"));
       
   614 	SqlServerSingleInsertTest(KSingleInsertSql, TheInsertRecId);
       
   615 
       
   616 	TheTest.Next(_L("SQL: update a single record"));
       
   617 	SqlServerSingleUpdateTest(KSingleUpdateSql, TheUpdateRecId);
       
   618 
       
   619 	TheTest.Next(_L("SQL: delete a single record"));
       
   620 	SqlServerSingleDeleteTest(KSingleDeleteSql, TheDeleteRecId);
       
   621 
       
   622 	TheTest.Next(_L("SQL: select a single record"));
       
   623 	SqlServerSingleSelectTest(KSingleSelectSql, TheSelectRecId);
       
   624 
       
   625 	(void)RSqlDatabase::Delete(KTestDbName);
       
   626 	}
       
   627 
       
   628 static void DoSqliteLibraryTests(TPerfTestMode aPerfTestMode)
       
   629 	{
       
   630 	TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
       
   631 
       
   632 	SqliteInitialize(aPerfTestMode);
       
   633 
       
   634 	TheTest.Next( _L("SQLite: Create the test database"));
       
   635 	CreateTestDatabase();
       
   636 
       
   637 	TBuf<200> msgbuf;
       
   638 	_LIT(KSqliteConfigSql, "\"SQL\"");
       
   639 	_LIT(KSqliteConfigDefault, "\"Default\"");
       
   640 
       
   641 	msgbuf.Format(_L("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4018: SQLite, configuration: %S: insert %d records in a single transaction"),
       
   642 							aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault, KInsertRecCnt);
       
   643 	TheTest.Next(msgbuf);
       
   644 	SqliteMultiInsertTest(aPerfTestMode, KMultiInsertSql, KInsertRecCnt);
       
   645 
       
   646 	msgbuf.Format(_L("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4019: SQLite, configuration: %S: update %d records in a single transaction"),
       
   647 							aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault, KUpdateRecCnt);
       
   648 	TheTest.Next(msgbuf);
       
   649 	SqliteMultiUpdateTest(aPerfTestMode, KMultiUpdateSql, TheUpdateRecIds, KUpdateRecCnt);
       
   650 
       
   651 	msgbuf.Format(_L("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4020: SQLite, configuration: %S: delete %d records in a single transaction"),
       
   652 							aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault, KDeleteRecCnt);
       
   653 	TheTest.Next(msgbuf);
       
   654 	SqliteMultiDeleteTest(aPerfTestMode, KMultiDeleteSql, TheDeleteRecIds, KDeleteRecCnt);
       
   655 
       
   656 	msgbuf.Format(_L("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4021: SQLite, configuration: %S: select %d records"),
       
   657 							aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault, KSelectRecCnt);
       
   658 	TheTest.Next(msgbuf);
       
   659 	SqliteMultiSelectTest(aPerfTestMode, KMultiSelectSql, TheSelectRecIds, KSelectRecCnt);
       
   660 
       
   661 	msgbuf.Format(_L("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4022: SQLite, configuration: %S: insert a single record"),
       
   662 							aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault);
       
   663 	TheTest.Next(msgbuf);
       
   664 	SqliteSingleInsertTest(aPerfTestMode, KSingleInsertSql, TheInsertRecId);
       
   665 
       
   666 	msgbuf.Format(_L("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4023: SQLite, configuration: %S: update a single record"),
       
   667 							aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault);
       
   668 	TheTest.Next(msgbuf);
       
   669 	SqliteSingleUpdateTest(aPerfTestMode, KSingleUpdateSql, TheUpdateRecId);
       
   670 
       
   671 	msgbuf.Format(_L("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4024: SQLite, configuration: %S: delete a single record"),
       
   672 							aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault);
       
   673 	TheTest.Next(msgbuf);
       
   674 	SqliteSingleDeleteTest(aPerfTestMode, KSingleDeleteSql, TheDeleteRecId);
       
   675 
       
   676 	msgbuf.Format(_L("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4025: SQLite, configuration: %S: select a single record"),
       
   677 							aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault);
       
   678 	TheTest.Next(msgbuf);
       
   679 	SqliteSingleSelectTest(aPerfTestMode, KSingleSelectSql, TheSelectRecId);
       
   680 
       
   681 	(void)RSqlDatabase::Delete(KTestDbName);
       
   682 
       
   683 	SqliteFinalize(aPerfTestMode);
       
   684 	}
       
   685 
       
   686 static TBool IdIn(TInt aId, const TInt aData[], TInt aDataSize)
       
   687 	{
       
   688 	TEST(aId > 0);
       
   689 	TEST(aDataSize >= 0);
       
   690 	for(TInt i=0;i<aDataSize;++i)
       
   691 		{
       
   692 		TEST(aData[i] > 0);
       
   693 		if(aData[i] == aId)
       
   694 			{
       
   695 			return ETrue;
       
   696 			}
       
   697 		}
       
   698 	return EFalse;
       
   699 	}
       
   700 
       
   701 static void VerifyGeneratedRecIds()
       
   702 	{
       
   703 	TInt i;
       
   704 
       
   705 	for(i=0;i<KUpdateRecCnt;++i)
       
   706 		{
       
   707 		TEST(TheUpdateRecIds[i] > 0 && TheUpdateRecIds[i] <= KInsertRecCnt);
       
   708 		TEST(!IdIn(TheUpdateRecIds[i], TheUpdateRecIds, i));
       
   709 		TEST(!IdIn(TheUpdateRecIds[i], TheDeleteRecIds, KDeleteRecCnt));
       
   710 		TEST(!IdIn(TheUpdateRecIds[i], TheSelectRecIds, KSelectRecCnt));
       
   711 		}
       
   712 
       
   713 	for(i=0;i<KDeleteRecCnt;++i)
       
   714 		{
       
   715 		TEST(TheDeleteRecIds[i] > 0 && TheDeleteRecIds[i] <= KInsertRecCnt);
       
   716 		TEST(!IdIn(TheDeleteRecIds[i], TheDeleteRecIds, i));
       
   717 		TEST(!IdIn(TheDeleteRecIds[i], TheUpdateRecIds, KUpdateRecCnt));
       
   718 		TEST(!IdIn(TheDeleteRecIds[i], TheSelectRecIds, KSelectRecCnt));
       
   719 		}
       
   720 
       
   721 	for(i=0;i<KSelectRecCnt;++i)
       
   722 		{
       
   723 		TEST(TheSelectRecIds[i] > 0 && TheSelectRecIds[i] <= KInsertRecCnt);
       
   724 		TEST(!IdIn(TheSelectRecIds[i], TheSelectRecIds, i));
       
   725 		TEST(!IdIn(TheSelectRecIds[i], TheUpdateRecIds, KUpdateRecCnt));
       
   726 		TEST(!IdIn(TheSelectRecIds[i], TheDeleteRecIds, KDeleteRecCnt));
       
   727 		}
       
   728 
       
   729 	TEST(TheInsertRecId > 0);
       
   730 
       
   731 	TEST(TheUpdateRecId > 0 && TheUpdateRecId <= KInsertRecCnt);
       
   732 	TEST(!IdIn(TheUpdateRecId, TheUpdateRecIds, KUpdateRecCnt));
       
   733 	TEST(!IdIn(TheUpdateRecId, TheDeleteRecIds, KDeleteRecCnt));
       
   734 	TEST(!IdIn(TheUpdateRecId, TheSelectRecIds, KSelectRecCnt));
       
   735 
       
   736 	TEST(TheDeleteRecId > 0 && TheDeleteRecId <= KInsertRecCnt);
       
   737 	TEST(!IdIn(TheDeleteRecId, TheUpdateRecIds, KUpdateRecCnt));
       
   738 	TEST(!IdIn(TheDeleteRecId, TheDeleteRecIds, KDeleteRecCnt));
       
   739 	TEST(!IdIn(TheDeleteRecId, TheSelectRecIds, KSelectRecCnt));
       
   740 
       
   741 	TEST(TheSelectRecId > 0 && TheSelectRecId <= KInsertRecCnt);
       
   742 	TEST(!IdIn(TheSelectRecId, TheUpdateRecIds, KUpdateRecCnt));
       
   743 	TEST(!IdIn(TheSelectRecId, TheDeleteRecIds, KDeleteRecCnt));
       
   744 	TEST(!IdIn(TheSelectRecId, TheSelectRecIds, KSelectRecCnt));
       
   745 	}
       
   746 
       
   747 static void GenerateTestRecIds()
       
   748 	{
       
   749 	TTime now;
       
   750 	now.UniversalTime();
       
   751 	TInt64 seed = now.Int64();
       
   752 	TInt i;
       
   753 
       
   754 	//Update multi
       
   755 	for(i=0;i<KUpdateRecCnt;)
       
   756 		{
       
   757 		TInt id = Math::Rand(seed) % KInsertRecCnt;
       
   758 		if(id > 0 && !IdIn(id, TheUpdateRecIds, i))
       
   759 			{
       
   760 			TheUpdateRecIds[i++] = id;
       
   761 			}
       
   762 		}
       
   763 	//Delete multi
       
   764 	for(i=0;i<KDeleteRecCnt;)
       
   765 		{
       
   766 		TInt id = Math::Rand(seed) % KInsertRecCnt;
       
   767 		if(id > 0 && !IdIn(id, TheDeleteRecIds, i) && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt))
       
   768 			{
       
   769 			TheDeleteRecIds[i++] = id;
       
   770 			}
       
   771 		}
       
   772 	//Select multi
       
   773 	for(i=0;i<KSelectRecCnt;)
       
   774 		{
       
   775 		TInt id = Math::Rand(seed) % KInsertRecCnt;
       
   776 		if(id > 0 && !IdIn(id, TheSelectRecIds, i) && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt) &&
       
   777 		             !IdIn(id, TheDeleteRecIds, KDeleteRecCnt))
       
   778 			{
       
   779 			TheSelectRecIds[i++] = id;
       
   780 			}
       
   781 		}
       
   782 	//Insert one
       
   783 	TheInsertRecId = KInsertRecCnt + 1;
       
   784 	//Update one
       
   785 	for(;;)
       
   786 		{
       
   787 		TInt id = Math::Rand(seed) % KInsertRecCnt;
       
   788 		if(id > 0 && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt) && !IdIn(id, TheDeleteRecIds, KDeleteRecCnt) &&
       
   789 		             !IdIn(id, TheSelectRecIds, KSelectRecCnt))
       
   790 			{
       
   791 			TheUpdateRecId = id;
       
   792 			break;
       
   793 			}
       
   794 		}
       
   795 	//Delete one
       
   796 	for(;;)
       
   797 		{
       
   798 		TInt id = Math::Rand(seed) % KInsertRecCnt;
       
   799 		if(id > 0 && id != TheUpdateRecId && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt) &&
       
   800 		                                     !IdIn(id, TheDeleteRecIds, KDeleteRecCnt) && !IdIn(id, TheSelectRecIds, KSelectRecCnt))
       
   801 			{
       
   802 			TheDeleteRecId = id;
       
   803 			break;
       
   804 			}
       
   805 		}
       
   806 	//Select one
       
   807 	for(;;)
       
   808 		{
       
   809 		TInt id = Math::Rand(seed) % KInsertRecCnt;
       
   810 		if(id > 0 && id != TheUpdateRecId && id != TheDeleteRecId && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt) &&
       
   811 		                                                             !IdIn(id, TheDeleteRecIds, KDeleteRecCnt) &&
       
   812 		                                                             !IdIn(id, TheSelectRecIds, KSelectRecCnt))
       
   813 			{
       
   814 			TheSelectRecId = id;
       
   815 			break;
       
   816 			}
       
   817 		}
       
   818 	}
       
   819 
       
   820 static void DoTests()
       
   821 	{
       
   822 	TheTest.Start(_L("Get fast counter frequency"));
       
   823 	GetFastCounterFrequency();
       
   824 
       
   825 	TheTest.Next( _L("Generate test record ids"));
       
   826 	GenerateTestRecIds();
       
   827 
       
   828 	TheTest.Next( _L("Verify generated test record ids"));
       
   829 	VerifyGeneratedRecIds();
       
   830 
       
   831 	DoSqlServerTests();
       
   832 	(void)KillProcess(KSqlSrvName);
       
   833 
       
   834 	DoSqliteLibraryTests(EPerfTestSqliteDefaultMode);
       
   835 	
       
   836 	DoSqliteLibraryTests(EPerfTestSqliteSqlMode);
       
   837 
       
   838 	PrintPerfTestResults();
       
   839 	}
       
   840 
       
   841 TInt E32Main()
       
   842 	{
       
   843 	TheTest.Title();
       
   844 
       
   845 	CTrapCleanup* tc = CTrapCleanup::New();
       
   846 
       
   847 	__UHEAP_MARK;
       
   848 
       
   849 	CreateTestDir();
       
   850 	DeleteTestFiles();
       
   851 	DoTests();
       
   852 	DeleteTestFiles();
       
   853 
       
   854 	__UHEAP_MARKEND;
       
   855 
       
   856 	TheTest.End();
       
   857 	TheTest.Close();
       
   858 
       
   859 	delete tc;
       
   860 
       
   861 	User::Heap().Check();
       
   862 	return KErrNone;
       
   863 	}