persistentstorage/sql/TEST/t_sqlperformance.cpp
branchRCL_3
changeset 21 fcc16690f446
parent 0 08ec8eefde2f
child 31 ba1c4f4a893f
equal deleted inserted replaced
20:04ec7606545c 21:fcc16690f446
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17 #include <e32math.h>
    17 #include <e32math.h>
    18 #include <bautils.h>
    18 #include <bautils.h>
    19 #include <hal.h>
    19 #include <hal.h>
    20 #include <stdlib.h>
    20 #include <stdlib.h>
    21 #include <sqldb.h>
    21 #include <sqldb.h>
       
    22 #include "t_sqlcmdlineutil.h"
    22 #include "SqlSrvStrings.h"
    23 #include "SqlSrvStrings.h"
    23 #include "sqlite3.h"
    24 #include "sqlite3.h"
    24 #include "SqliteSymbian.h"
    25 #include "SqliteSymbian.h"
    25 
    26 
    26 ///////////////////////////////////////////////////////////////////////////////////////
    27 ///////////////////////////////////////////////////////////////////////////////////////
    27 
    28 
    28 RTest TheTest(_L("t_sqlperformance test"));
    29 RTest TheTest(_L("t_sqlperformance test"));
    29 RFs   TheFs;
    30 RFs   TheFs;
    30 
       
    31 TBuf<200> TheTestTitle;
    31 TBuf<200> TheTestTitle;
    32 TBuf<256> TheCmd;
    32 TCmdLineParams TheCmdLineParams;
    33 TParse TheParse;
    33 TBuf8<200> TheSqlConfigString;
    34 TBuf<8> TheDriveName;
    34 
    35 
    35 _LIT(KUtf8,  "UTF8 ");
    36 _LIT8(KDbEncodingUtf8, "encoding=UTF-8");
    36 _LIT(KUtf16, "UTF16");
    37 _LIT(KDbEncodingUtf8text,  "UTF8  encoded db");
       
    38 _LIT(KDbEncodingUtf16text, "UTF16 encoded db");
       
    39 
    37 
    40 TFileName TheSecureDbName;
    38 TFileName TheSecureDbName;
    41 TFileName TheNonSecureDbName;
    39 TFileName TheNonSecureDbName;
    42 TFileName TheNonSecureDbName2;
    40 TFileName TheNonSecureDbName2;
    43 TFileName TheNonSecureTmpDbName;
    41 TFileName TheNonSecureTmpDbName;
    44 TFileName TheSglRecDbFileName;
    42 TFileName TheSglRecDbFileName;
    45 
    43 
    46 enum TDbEncoding
       
    47 	{
       
    48 	EDbUtf8,
       
    49 	EDbUtf16
       
    50 	};
       
    51 	
       
    52 TDbEncoding TheDbEncoding;
       
    53 
       
    54 _LIT(KSqlServerPrivateDir, "\\private\\10281e17\\");
    44 _LIT(KSqlServerPrivateDir, "\\private\\10281e17\\");
    55 
    45 
    56 _LIT(KCreateDbScript, "z:\\test\\contacts_schema_to_vendors.sql");
    46 _LIT(KCreateDbScript, "z:\\test\\contacts_schema_to_vendors.sql");
    57 _LIT(KFillDbScript, "z:\\test\\add_simple_contacts.sql");
    47 _LIT(KFillDbScript, "z:\\test\\add_simple_contacts.sql");
    58 
    48 
   155 	TPtr8 ptr = sql->Des();
   145 	TPtr8 ptr = sql->Des();
   156 	TEST2(file.Read(ptr, size), KErrNone);
   146 	TEST2(file.Read(ptr, size), KErrNone);
   157 
   147 
   158 	file.Close();
   148 	file.Close();
   159 	
   149 	
   160 	HBUFC* sql2 = HBUFC::New(size);
   150 	HBUFC* sql2 = HBUFC::New(size + 1);
   161 	TEST(sql2 != NULL);
   151 	TEST(sql2 != NULL);
   162 	sql2->Des().Copy(sql->Des());
   152 	sql2->Des().Copy(sql->Des());
       
   153 	sql2->Des().Append(TChar(0));
   163 	delete sql;
   154 	delete sql;
   164 	
   155 	
   165 	return sql2;
   156 	return sql2;
   166 	}
   157 	}
   167 //Explicit ReadSqlScript() template instantiations.
   158 //Explicit ReadSqlScript() template instantiations.
   247 public:	
   238 public:	
   248 	static void Create(const TDesC& aDbName)
   239 	static void Create(const TDesC& aDbName)
   249 		{
   240 		{
   250 		RSqlDatabase::Delete(aDbName);
   241 		RSqlDatabase::Delete(aDbName);
   251 		RSqlDatabase db;
   242 		RSqlDatabase db;
   252 		TInt err = db.Create(aDbName, TheDbEncoding == EDbUtf16 ? NULL : &KDbEncodingUtf8);
   243 		TInt err = db.Create(aDbName, &TheSqlConfigString);
   253 		TEST2(err, KErrNone);
   244 		TEST2(err, KErrNone);
   254 		CreateDbSchema(db);
   245 		CreateDbSchema(db);
   255 		db.Close();
   246 		db.Close();
   256 		}
   247 		}
   257 	static RSqlDatabase Open(const TDesC& aDbName)
   248 	static RSqlDatabase Open(const TDesC& aDbName)
   275 		TEST2(err, KErrNone);	
   266 		TEST2(err, KErrNone);	
   276 		securityPolicy.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, TSecurityPolicy(ECapabilityReadUserData, ECapabilityWriteUserData));
   267 		securityPolicy.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, TSecurityPolicy(ECapabilityReadUserData, ECapabilityWriteUserData));
   277 		securityPolicy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, TSecurityPolicy(ECapabilityWriteUserData));
   268 		securityPolicy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, TSecurityPolicy(ECapabilityWriteUserData));
   278 		securityPolicy.SetDbPolicy(RSqlSecurityPolicy::EReadPolicy, TSecurityPolicy(ECapabilityReadUserData));
   269 		securityPolicy.SetDbPolicy(RSqlSecurityPolicy::EReadPolicy, TSecurityPolicy(ECapabilityReadUserData));
   279 		RSqlDatabase db;
   270 		RSqlDatabase db;
   280 		err = db.Create(aDbName, securityPolicy, TheDbEncoding == EDbUtf16 ? NULL : &KDbEncodingUtf8);
   271 		err = db.Create(aDbName, securityPolicy, &TheSqlConfigString);
   281 		TEST2(err, KErrNone);	
   272 		TEST2(err, KErrNone);	
   282 		securityPolicy.Close();
   273 		securityPolicy.Close();
   283 		CreateDbSchema(db);
   274 		CreateDbSchema(db);
   284 		db.Close();
   275 		db.Close();
   285 		}
   276 		}
   503 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   494 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   504 ///////     SQLITE API used directly  
   495 ///////     SQLITE API used directly  
   505 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   496 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   506 
   497 
   507 //Template class offering Create() and Open() methods for creating/opening a sqlite3 handle.
   498 //Template class offering Create() and Open() methods for creating/opening a sqlite3 handle.
   508 template <TDbEncoding TYPE> class TDbHelper2
   499 template <TCmdLineParams::TDbEncoding TYPE> class TDbHelper2
   509 	{
   500 	{
   510 public:	
   501 public:	
   511 	static void Create(const TDesC& aDbName);
   502 	static void Create(const TDesC& aDbName);
   512 	static sqlite3* Open(const TDesC& aDbName);
   503 	static sqlite3* Open(const TDesC& aDbName);
   513 	};
   504 	};
   541   		}
   532   		}
   542   	return EFalse;
   533   	return EFalse;
   543 	}
   534 	}
   544 
   535 
   545 //Explicit TDbHelper2 class specialization for creating/opening a database with UTF8 default encoding
   536 //Explicit TDbHelper2 class specialization for creating/opening a database with UTF8 default encoding
   546 template <> class TDbHelper2<EDbUtf8>
   537 template <> class TDbHelper2<TCmdLineParams::EDbUtf8>
   547 	{
   538 	{
   548 public:	
   539 public:	
   549 	static void Create(const TDesC& aDbFileName)
   540 	static void Create(const TDesC& aDbFileName)
   550 		{
   541 		{
   551 		(void)TheFs.Delete(aDbFileName);
   542 		(void)TheFs.Delete(aDbFileName);
   579 		return dbHandle;
   570 		return dbHandle;
   580 		}
   571 		}
   581 	};
   572 	};
   582 
   573 
   583 //Explicit TDbHelper2 class specialization for creating/opening a database with UTF16 default encoding
   574 //Explicit TDbHelper2 class specialization for creating/opening a database with UTF16 default encoding
   584 template <> class TDbHelper2<EDbUtf16>
   575 template <> class TDbHelper2<TCmdLineParams::EDbUtf16>
   585 	{
   576 	{
   586 public:	
   577 public:	
   587 	static void Create(const TDesC& aDbFileName)
   578 	static void Create(const TDesC& aDbFileName)
   588 		{
   579 		{
   589 		(void)TheFs.Delete(aDbFileName);
   580 		(void)TheFs.Delete(aDbFileName);
   812 	TheTest.Printf(_L("\"Update (without parameters)\" test\r\n"));
   803 	TheTest.Printf(_L("\"Update (without parameters)\" test\r\n"));
   813 	TBuf<200> fmtstr;
   804 	TBuf<200> fmtstr;
   814 	fmtstr.Copy(aUpdateSql);
   805 	fmtstr.Copy(aUpdateSql);
   815 
   806 
   816 	sqlite3SymbianLibInit();
   807 	sqlite3SymbianLibInit();
   817 	sqlite3* dbHandle = TDbHelper2<EDbUtf8>::Open(aDbName);
   808 	sqlite3* dbHandle = TDbHelper2<TCmdLineParams::EDbUtf8>::Open(aDbName);
   818 	
   809 	
   819 	TUint32 start = User::FastCounter();
   810 	TUint32 start = User::FastCounter();
   820 	for(TInt id=1;id<=KTestTecordCount;++id)
   811 	for(TInt id=1;id<=KTestTecordCount;++id)
   821 		{
   812 		{
   822 		TBuf<200> buf;
   813 		TBuf<200> buf;
   840 template <> void UpdateWPTest2<TDesC16>(const TDesC& aDbName, const TDesC16& aUpdateSql)
   831 template <> void UpdateWPTest2<TDesC16>(const TDesC& aDbName, const TDesC16& aUpdateSql)
   841 	{
   832 	{
   842 	TheTest.Printf(_L("\"Update (without parameters)\" test\r\n"));
   833 	TheTest.Printf(_L("\"Update (without parameters)\" test\r\n"));
   843 
   834 
   844 	sqlite3SymbianLibInit();
   835 	sqlite3SymbianLibInit();
   845 	sqlite3* dbHandle = TDbHelper2<EDbUtf16>::Open(aDbName);
   836 	sqlite3* dbHandle = TDbHelper2<TCmdLineParams::EDbUtf16>::Open(aDbName);
   846 	
   837 	
   847 	TUint32 start = User::FastCounter();
   838 	TUint32 start = User::FastCounter();
   848 	for(TInt id=1;id<=KTestTecordCount;++id)
   839 	for(TInt id=1;id<=KTestTecordCount;++id)
   849 		{
   840 		{
   850 		TBuf<200> sql;
   841 		TBuf<200> sql;
   996 	TUint32 end = User::FastCounter();
   987 	TUint32 end = User::FastCounter();
   997 	PrintStats(start, end);
   988 	PrintStats(start, end);
   998 	delete sql;
   989 	delete sql;
   999 	}
   990 	}
  1000 
   991 
  1001 template <TDbEncoding TYPE, class HBUFC, class PTRC, class DESC> void PerformanceTest2(const TDesC& aDbFileName, 
   992 template <TCmdLineParams::TDbEncoding TYPE, class HBUFC, class PTRC, class DESC> void PerformanceTest2(
       
   993 																					   const TDesC& aDbFileName, 
  1002 																					   const DESC& aCommitStr,
   994 																					   const DESC& aCommitStr,
  1003 																					   const DESC& aUpdateSql,
   995 																					   const DESC& aUpdateSql,
  1004 																					   const DESC& aSelectSql,
   996 																					   const DESC& aSelectSql,
  1005 																					   const DESC& aDeleteSql)
   997 																					   const DESC& aDeleteSql)
  1006 	{
   998 	{
  1037 	(void)fm->Copy(TheNonSecureTmpDbName, aDbFileName);
  1029 	(void)fm->Copy(TheNonSecureTmpDbName, aDbFileName);
  1038 	(void)fm->Delete(TheNonSecureTmpDbName);
  1030 	(void)fm->Delete(TheNonSecureTmpDbName);
  1039 	delete fm;
  1031 	delete fm;
  1040 	}
  1032 	}
  1041 //Explicit PerformanceTest2() template instantiations.
  1033 //Explicit PerformanceTest2() template instantiations.
  1042 template void PerformanceTest2<EDbUtf8, HBufC8, TPtrC8, TDesC8>(const TDesC&, const TDesC8&, const TDesC8&, const TDesC8&, const TDesC8&);
  1034 template void PerformanceTest2<TCmdLineParams::EDbUtf8, HBufC8, TPtrC8, TDesC8>(const TDesC&, const TDesC8&, const TDesC8&, const TDesC8&, const TDesC8&);
  1043 template void PerformanceTest2<EDbUtf16, HBufC8, TPtrC8, TDesC8>(const TDesC&, const TDesC8&, const TDesC8&, const TDesC8&, const TDesC8&);
  1035 template void PerformanceTest2<TCmdLineParams::EDbUtf16, HBufC8, TPtrC8, TDesC8>(const TDesC&, const TDesC8&, const TDesC8&, const TDesC8&, const TDesC8&);
  1044 template void PerformanceTest2<EDbUtf8, HBufC16, TPtrC16, TDesC16>(const TDesC&, const TDesC16&, const TDesC16&, const TDesC16&, const TDesC16&);
  1036 template void PerformanceTest2<TCmdLineParams::EDbUtf8, HBufC16, TPtrC16, TDesC16>(const TDesC&, const TDesC16&, const TDesC16&, const TDesC16&, const TDesC16&);
  1045 template void PerformanceTest2<EDbUtf16, HBufC16, TPtrC16, TDesC16>(const TDesC&, const TDesC16&, const TDesC16&, const TDesC16&, const TDesC16&);
  1037 template void PerformanceTest2<TCmdLineParams::EDbUtf16, HBufC16, TPtrC16, TDesC16>(const TDesC&, const TDesC16&, const TDesC16&, const TDesC16&, const TDesC16&);
  1046 
  1038 
  1047 void ColumnValueAccessTest()
  1039 void ColumnValueAccessTest()
  1048 	{
  1040 	{
  1049 	_LIT(KColName1, "Column1");
  1041 	_LIT(KColName1, "Column1");
  1050 	_LIT(KColName2, "Column2");
  1042 	_LIT(KColName2, "Column2");
  1054 	TPtrC colNames[KColCount] = {KColName1(), KColName2(), KColName3(), KColName4()};
  1046 	TPtrC colNames[KColCount] = {KColName1(), KColName2(), KColName3(), KColName4()};
  1055 	TBuf<100> sql;
  1047 	TBuf<100> sql;
  1056 	
  1048 	
  1057 	//Create a test database
  1049 	//Create a test database
  1058 	RSqlDatabase db;
  1050 	RSqlDatabase db;
  1059 	TInt err = db.Create(TheNonSecureDbName2);		
  1051 	TInt err = db.Create(TheNonSecureDbName2, &TheSqlConfigString);
  1060 	TEST2(err, KErrNone);
  1052 	TEST2(err, KErrNone);
  1061 	_LIT(KCreateSql, "CREATE TABLE A(%S INTEGER, %S INTEGER, %S INTEGER, %S INTEGER)");
  1053 	_LIT(KCreateSql, "CREATE TABLE A(%S INTEGER, %S INTEGER, %S INTEGER, %S INTEGER)");
  1062 	sql.Format(KCreateSql, &colNames[0], &colNames[1], &colNames[2], &colNames[3]);
  1054 	sql.Format(KCreateSql, &colNames[0], &colNames[1], &colNames[2], &colNames[3]);
  1063 	err = db.Exec(sql);
  1055 	err = db.Exec(sql);
  1064 	TEST(err >= 0);	
  1056 	TEST(err >= 0);	
  1257 	SingleInsertTest();
  1249 	SingleInsertTest();
  1258 	
  1250 	
  1259 	TheTest.Printf(_L("Single \"delete\" test\r\n"));
  1251 	TheTest.Printf(_L("Single \"delete\" test\r\n"));
  1260 	SingleDeleteTest();
  1252 	SingleDeleteTest();
  1261 	
  1253 	
  1262 	TheTestTitle.Copy(_L("SERVER, UTF8 SQL strings, non-secure, "));
  1254 	TheTestTitle.Format(_L("SERVER, UTF8 SQL strings, non-secure, encoding: \"%S\", page size: %d\r\n"), 
  1263 	TheTestTitle.Append(TheDbEncoding == EDbUtf16 ? KDbEncodingUtf16text : KDbEncodingUtf8text);
  1255 			TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
  1264 	TheTestTitle.Append(_L("\r\n"));
       
  1265 	TheTest.Printf(TheTestTitle);
  1256 	TheTest.Printf(TheTestTitle);
  1266 	PerformanceTest<HBufC8, TPtrC8, TDesC8, ENonSecureDb>(TheNonSecureDbName, KCommitStr8(), KUpdateSql8(), KSelectSql8(), KDeleteSql8());
  1257 	PerformanceTest<HBufC8, TPtrC8, TDesC8, ENonSecureDb>(TheNonSecureDbName, KCommitStr8(), KUpdateSql8(), KSelectSql8(), KDeleteSql8());
  1267 
  1258 
  1268 	TheTestTitle.Copy(_L("SERVER, UTF8 SQL strings, non-secure, "));
  1259 	TheTestTitle.Format(_L("SERVER, UTF8 SQL strings, non-secure, update test (without parameters), encoding: \"%S\", page size: %d\r\n"), 
  1269 	TheTestTitle.Append(TheDbEncoding == EDbUtf16 ? KDbEncodingUtf16text : KDbEncodingUtf8text);
  1260 			TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
  1270 	TheTestTitle.Append(_L(", update test (without parameters)"));
       
  1271 	TheTestTitle.Append(_L("\r\n"));
       
  1272 	TheTest.Printf(TheTestTitle);
  1261 	TheTest.Printf(TheTestTitle);
  1273 	UpdateWPTest<TBuf8<200>, TDesC8, ENonSecureDb>(TheNonSecureDbName, KUpdateSql2_8());
  1262 	UpdateWPTest<TBuf8<200>, TDesC8, ENonSecureDb>(TheNonSecureDbName, KUpdateSql2_8());
  1274 
  1263 
  1275 	TheTestTitle.Copy(_L("SERVER, UTF8 SQL strings, secure, "));
  1264 	TheTestTitle.Format(_L("SERVER, UTF8 SQL strings, secure, encoding: \"%S\", page size: %d\r\n"), 
  1276 	TheTestTitle.Append(TheDbEncoding == EDbUtf16 ? KDbEncodingUtf16text : KDbEncodingUtf8text);
  1265 			TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
  1277 	TheTestTitle.Append(_L("\r\n"));
       
  1278 	TheTest.Printf(TheTestTitle);
  1266 	TheTest.Printf(TheTestTitle);
  1279 	PerformanceTest<HBufC8, TPtrC8, TDesC8, ESecureDb>(TheSecureDbName, KCommitStr8(), KUpdateSql8(), KSelectSql8(), KDeleteSql8());
  1267 	PerformanceTest<HBufC8, TPtrC8, TDesC8, ESecureDb>(TheSecureDbName, KCommitStr8(), KUpdateSql8(), KSelectSql8(), KDeleteSql8());
  1280 
  1268 
  1281 	TheTest.Printf(_L("SQLITE, UTF8 encoded database, UTF8 SQL strings\r\n"));
  1269 	TheTest.Printf(_L("SQLITE, UTF8 encoded database, UTF8 SQL strings\r\n"));
  1282 	PerformanceTest2<EDbUtf8, HBufC8, TPtrC8, TDesC8>(TheNonSecureDbName, KCommitStr8(), KUpdateSql8(), KSelectSql8(), KDeleteSql8());
  1270 	PerformanceTest2<TCmdLineParams::EDbUtf8, HBufC8, TPtrC8, TDesC8>(TheNonSecureDbName, KCommitStr8(), KUpdateSql8(), KSelectSql8(), KDeleteSql8());
  1283 
  1271 
  1284 	TheTest.Printf(_L("SQLITE, UTF8 encoded database, UTF8 SQL strings, update test (without parameters)\r\n"));
  1272 	TheTest.Printf(_L("SQLITE, UTF8 encoded database, UTF8 SQL strings, update test (without parameters)\r\n"));
  1285 	UpdateWPTest2<TDesC8>(TheNonSecureDbName, KUpdateSql2_8());
  1273 	UpdateWPTest2<TDesC8>(TheNonSecureDbName, KUpdateSql2_8());
  1286 
  1274 
  1287 	TheTest.Printf(_L("SQLITE, UTF16 encoded database, UTF8 SQL strings\r\n"));
  1275 	TheTest.Printf(_L("SQLITE, UTF16 encoded database, UTF8 SQL strings\r\n"));
  1288 	PerformanceTest2<EDbUtf16, HBufC8, TPtrC8, TDesC8>(TheNonSecureDbName, KCommitStr8(), KUpdateSql8(), KSelectSql8(), KDeleteSql8());
  1276 	PerformanceTest2<TCmdLineParams::EDbUtf16, HBufC8, TPtrC8, TDesC8>(TheNonSecureDbName, KCommitStr8(), KUpdateSql8(), KSelectSql8(), KDeleteSql8());
  1289 
  1277 
  1290 	TheTestTitle.Copy(_L("SERVER, UTF16 SQL strings, non-secure, "));
  1278 	TheTestTitle.Format(_L("SERVER, UTF16 SQL strings, non-secure, encoding: \"%S\", page size: %d\r\n"), 
  1291 	TheTestTitle.Append(TheDbEncoding == EDbUtf16 ? KDbEncodingUtf16text : KDbEncodingUtf8text);
  1279 			TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
  1292 	TheTestTitle.Append(_L("\r\n"));
       
  1293 	TheTest.Printf(TheTestTitle);
  1280 	TheTest.Printf(TheTestTitle);
  1294 	PerformanceTest<HBufC16, TPtrC16, TDesC16, ENonSecureDb>(TheNonSecureDbName, KCommitStr16(), KUpdateSql16(), KSelectSql16(), KDeleteSql16());
  1281 	PerformanceTest<HBufC16, TPtrC16, TDesC16, ENonSecureDb>(TheNonSecureDbName, KCommitStr16(), KUpdateSql16(), KSelectSql16(), KDeleteSql16());
  1295 	
  1282 	
  1296 	TheTestTitle.Copy(_L("SERVER, UTF16 SQL strings, non-secure, "));
  1283 	TheTestTitle.Format(_L("SERVER, UTF16 SQL strings, non-secure, update test (without parameters), encoding: \"%S\", page size: %d\r\n"), 
  1297 	TheTestTitle.Append(TheDbEncoding == EDbUtf16 ? KDbEncodingUtf16text : KDbEncodingUtf8text);
  1284 			TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
  1298 	TheTestTitle.Append(_L(", update test (without parameters)\r\n"));
       
  1299 	TheTest.Printf(TheTestTitle);
  1285 	TheTest.Printf(TheTestTitle);
  1300 	UpdateWPTest<TBuf16<200>, TDesC16, ENonSecureDb>(TheNonSecureDbName, KUpdateSql2_16());
  1286 	UpdateWPTest<TBuf16<200>, TDesC16, ENonSecureDb>(TheNonSecureDbName, KUpdateSql2_16());
  1301 
  1287 
  1302 	TheTestTitle.Copy(_L("SERVER, UTF16 SQL strings, secure, "));
  1288 	TheTestTitle.Format(_L("SERVER, UTF16 SQL strings, secure, encoding: \"%S\", page size: %d\r\n"), 
  1303 	TheTestTitle.Append(TheDbEncoding == EDbUtf16 ? KDbEncodingUtf16text : KDbEncodingUtf8text);
  1289 			TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
  1304 	TheTestTitle.Append(_L("\r\n"));
       
  1305 	TheTest.Printf(TheTestTitle);
  1290 	TheTest.Printf(TheTestTitle);
  1306 	PerformanceTest<HBufC16, TPtrC16, TDesC16, ESecureDb>(TheSecureDbName, KCommitStr16(), KUpdateSql16(), KSelectSql16(), KDeleteSql16());
  1291 	PerformanceTest<HBufC16, TPtrC16, TDesC16, ESecureDb>(TheSecureDbName, KCommitStr16(), KUpdateSql16(), KSelectSql16(), KDeleteSql16());
  1307 
  1292 
  1308 	TheTest.Printf(_L("SQLITE, UTF8 encoded database, UTF16 SQL strings\r\n"));
  1293 	TheTest.Printf(_L("SQLITE, UTF8 encoded database, UTF16 SQL strings\r\n"));
  1309 	PerformanceTest2<EDbUtf8, HBufC16, TPtrC16, TDesC16>(TheNonSecureDbName, KCommitStr16(), KUpdateSql16(), KSelectSql16(), KDeleteSql16());
  1294 	PerformanceTest2<TCmdLineParams::EDbUtf8, HBufC16, TPtrC16, TDesC16>(TheNonSecureDbName, KCommitStr16(), KUpdateSql16(), KSelectSql16(), KDeleteSql16());
  1310 
  1295 
  1311 	TheTest.Printf(_L("SQLITE, UTF16 encoded database, UTF16 SQL strings\r\n"));
  1296 	TheTest.Printf(_L("SQLITE, UTF16 encoded database, UTF16 SQL strings\r\n"));
  1312 	PerformanceTest2<EDbUtf16, HBufC16, TPtrC16, TDesC16>(TheNonSecureDbName, KCommitStr16(), KUpdateSql16(), KSelectSql16(), KDeleteSql16());
  1297 	PerformanceTest2<TCmdLineParams::EDbUtf16, HBufC16, TPtrC16, TDesC16>(TheNonSecureDbName, KCommitStr16(), KUpdateSql16(), KSelectSql16(), KDeleteSql16());
  1313 
  1298 
  1314 	TheTest.Printf(_L("SQLITE, UTF16 encoded database, UTF16 SQL strings, update test (without parameters)\r\n"));
  1299 	TheTest.Printf(_L("SQLITE, UTF16 encoded database, UTF16 SQL strings, update test (without parameters)\r\n"));
  1315 	UpdateWPTest2<TDesC16>(TheNonSecureDbName, KUpdateSql2_16());
  1300 	UpdateWPTest2<TDesC16>(TheNonSecureDbName, KUpdateSql2_16());
  1316 
  1301 
  1317 	TheTest.Printf(_L("Accessing column value by index or by name\r\n"));
  1302 	TheTest.Printf(_L("Accessing column value by index or by name\r\n"));
  1320 	TheTest.Printf(_L("Retrieving data from UTF8 Database using SELECT LIKE statements\r\n"));
  1305 	TheTest.Printf(_L("Retrieving data from UTF8 Database using SELECT LIKE statements\r\n"));
  1321 	SelectLikeQueryPerfTest();
  1306 	SelectLikeQueryPerfTest();
  1322 
  1307 
  1323 	}
  1308 	}
  1324 
  1309 
  1325 //Usage: "t_sqlperformance [[-16/-8] [<drive letter>:]]"
       
  1326 
       
  1327 TInt E32Main()
  1310 TInt E32Main()
  1328 	{
  1311 	{
  1329 	TheTest.Title();
  1312 	TheTest.Title();
  1330 
  1313 
  1331 	CTrapCleanup* tc = CTrapCleanup::New();
  1314 	CTrapCleanup* tc = CTrapCleanup::New();
  1332 
  1315 	TheTest(tc != NULL);
  1333 	TheDbEncoding = EDbUtf16;
  1316 
  1334 
  1317 	GetCmdLineParamsAndSqlConfigString(TheTest, _L("t_sqlperformance"), TheCmdLineParams, TheSqlConfigString);
  1335 	User::CommandLine(TheCmd);
       
  1336 	TheCmd.TrimAll();
       
  1337 	if(TheCmd.Length() > 0)
       
  1338 		{
       
  1339 		TPtrC prm1(KNullDesC);
       
  1340 		TPtrC prm2(KNullDesC);
       
  1341 		TInt pos = TheCmd.Locate(TChar(' '));
       
  1342 		if(pos > 0)
       
  1343 			{
       
  1344 			prm1.Set(TheCmd.Left(pos));
       
  1345 			prm2.Set(TheCmd.Mid(pos + 1));
       
  1346 			}
       
  1347 		else
       
  1348 			{
       
  1349 			prm1.Set(TheCmd);
       
  1350 			}
       
  1351 		if(prm1.Compare(_L("-8")) == 0)
       
  1352 			{
       
  1353 			TheDbEncoding = EDbUtf8;
       
  1354 			TheDriveName.Copy(prm2);
       
  1355 			}
       
  1356 		else if(prm2.Compare(_L("-8")) == 0)
       
  1357 			{
       
  1358 			TheDbEncoding = EDbUtf8;
       
  1359 			TheDriveName.Copy(prm1);
       
  1360 			}
       
  1361 		else if(prm1.Compare(_L("-16")) == 0)
       
  1362 			{
       
  1363 			TheDbEncoding = EDbUtf16;
       
  1364 			TheDriveName.Copy(prm2);
       
  1365 			}
       
  1366 		else if(prm2.Compare(_L("-16")) == 0)
       
  1367 			{
       
  1368 			TheDbEncoding = EDbUtf16;
       
  1369 			TheDriveName.Copy(prm1);
       
  1370 			}
       
  1371 		}
       
  1372 
       
  1373 	//Construct test database file names	
       
  1374 	_LIT(KSecureDbName, "c:[2121212A]t_perfdb.db");
  1318 	_LIT(KSecureDbName, "c:[2121212A]t_perfdb.db");
  1375 	TheParse.Set(TheDriveName, &KSecureDbName, 0);
  1319 	PrepareDbName(KSecureDbName, TheCmdLineParams.iDriveName, TheSecureDbName);
  1376 	const TDesC& dbFilePath1 = TheParse.FullName();
       
  1377 	TheSecureDbName.Copy(dbFilePath1);
       
  1378 	
       
  1379 	_LIT(KNonSecureDbName, "c:\\test\\t_perfdb.db");
  1320 	_LIT(KNonSecureDbName, "c:\\test\\t_perfdb.db");
  1380 	TheParse.Set(TheDriveName, &KNonSecureDbName, 0);
  1321 	PrepareDbName(KNonSecureDbName, TheCmdLineParams.iDriveName, TheNonSecureDbName);
  1381 	const TDesC& dbFilePath2 = TheParse.FullName();
       
  1382 	TheNonSecureDbName.Copy(dbFilePath2);
       
  1383 	
       
  1384 	_LIT(KNonSecureDbName2, "c:\\test\\t_perfdb2.db");
  1322 	_LIT(KNonSecureDbName2, "c:\\test\\t_perfdb2.db");
  1385 	TheParse.Set(TheDriveName, &KNonSecureDbName2, 0);
  1323 	PrepareDbName(KNonSecureDbName2, TheCmdLineParams.iDriveName, TheNonSecureDbName2);
  1386 	const TDesC& dbFilePath3 = TheParse.FullName();
       
  1387 	TheNonSecureDbName2.Copy(dbFilePath3);
       
  1388 
       
  1389 	_LIT(KNonSecureTmpDbName, "c:\\test\\tmp.db");
  1324 	_LIT(KNonSecureTmpDbName, "c:\\test\\tmp.db");
  1390 	TheParse.Set(TheDriveName, &KNonSecureTmpDbName, 0);
  1325 	PrepareDbName(KNonSecureTmpDbName, TheCmdLineParams.iDriveName, TheNonSecureTmpDbName);
  1391 	const TDesC& dbFilePath4 = TheParse.FullName();
       
  1392 	TheNonSecureTmpDbName.Copy(dbFilePath4);
       
  1393 	
       
  1394 	_LIT(KSglRecDbName, "c:\\test\\default_avacon.dbSQL");
  1326 	_LIT(KSglRecDbName, "c:\\test\\default_avacon.dbSQL");
  1395 	TheParse.Set(TheDriveName, &KSglRecDbName, 0);
  1327 	PrepareDbName(KSglRecDbName, TheCmdLineParams.iDriveName, TheSglRecDbFileName);
  1396 	const TDesC& dbFilePath5 = TheParse.FullName();
  1328 
  1397 	TheSglRecDbFileName.Copy(dbFilePath5);
  1329 	TheTest.Printf(_L("==Databases: %S, %S, %S, %S, %S\r\n"), &TheSecureDbName, &TheNonSecureDbName, 
       
  1330 															  &TheNonSecureDbName2, &TheNonSecureTmpDbName, 
       
  1331 															  &TheSglRecDbFileName);
  1398 	
  1332 	
  1399 	__UHEAP_MARK;
  1333 	__UHEAP_MARK;
  1400 	
  1334 	
  1401 	TestEnvInit();
  1335 	TestEnvInit();
  1402 	TheTest.Printf(_L("==Databases: %S, %S, %S, %S, %S\r\n"), &TheSecureDbName, &TheNonSecureDbName, 
       
  1403 															  &TheNonSecureDbName2, &TheNonSecureTmpDbName, &TheSglRecDbFileName);
       
  1404 	DoTests();
  1336 	DoTests();
  1405 	TestEnvDestroy();
  1337 	TestEnvDestroy();
  1406 
  1338 
  1407 	__UHEAP_MARKEND;
  1339 	__UHEAP_MARKEND;
  1408 	
  1340