persistentstorage/dbms/tdbms/t_dbperf1.cpp
changeset 55 44f437012c90
parent 0 08ec8eefde2f
equal deleted inserted replaced
51:7d4490026038 55:44f437012c90
     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".
    16 #include <e32test.h>
    16 #include <e32test.h>
    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 <d32dbms.h>
    20 #include <d32dbms.h>
       
    21 #include "t_dbcmdlineutil.h"
    21 
    22 
    22 ///////////////////////////////////////////////////////////////////////////////////////
    23 ///////////////////////////////////////////////////////////////////////////////////////
    23 
    24 
    24 RTest TheTest(_L("t_dbperf1"));
    25 RTest TheTest(_L("t_dbperf1"));
    25 RFs   TheFs;
    26 RFs   TheFs;
    50 	ECompactAfterEvery10Rec,
    51 	ECompactAfterEvery10Rec,
    51 	ECompactAfterEveryUpd,
    52 	ECompactAfterEveryUpd,
    52 	ECompactAtEnd
    53 	ECompactAtEnd
    53 	};
    54 	};
    54 	
    55 	
       
    56 TCmdLineParams TheCmdLineParams;
       
    57 RFile TheLogFile; 
       
    58 TBuf<250> TheLogLine;
       
    59 TBuf8<250> TheLogLine8;
       
    60 TBuf<200> TheTestTitle;
       
    61 
    55 ///////////////////////////////////////////////////////////////////////////////////////
    62 ///////////////////////////////////////////////////////////////////////////////////////
    56 
    63 
    57 void TestEnvDestroy()
    64 void TestEnvDestroy()
    58 	{
    65 	{
    59 	TheDbs.Close();
    66 	TheDbs.Close();
    60 	TheFs.Delete(TheNonSecureDbName2);
    67 	TheFs.Delete(TheNonSecureDbName2);
    61 	TheFs.Delete(TheNonSecureDbName);
    68 	TheFs.Delete(TheNonSecureDbName);
       
    69 	if(TheCmdLineParams.iLogFileName.Length() > 0)
       
    70 		{
       
    71 		(void)TheLogFile.Flush();
       
    72 		TheLogFile.Close();
       
    73 		}
    62 	TheFs.Close();
    74 	TheFs.Close();
    63 	}
    75 	}
    64 
    76 
    65 ///////////////////////////////////////////////////////////////////////////////////////
    77 ///////////////////////////////////////////////////////////////////////////////////////
    66 ///////////////////////////////////////////////////////////////////////////////////////
    78 ///////////////////////////////////////////////////////////////////////////////////////
    68 void Check1(TInt aValue, TInt aLine)
    80 void Check1(TInt aValue, TInt aLine)
    69 	{
    81 	{
    70 	if(!aValue)
    82 	if(!aValue)
    71 		{
    83 		{
    72 		TestEnvDestroy();
    84 		TestEnvDestroy();
    73 		TheTest.Printf(_L("*** Line %d\r\n"), aLine);
    85 		TheTest.Printf(_L("*** Line %d. Expression evaluated to false\r\n"), aLine);
    74 		TheTest(EFalse, aLine);
    86 		TheTest(EFalse, aLine);
    75 		}
    87 		}
    76 	}
    88 	}
    77 void Check2(TInt aValue, TInt aExpected, TInt aLine)
    89 void Check2(TInt aValue, TInt aExpected, TInt aLine)
    78 	{
    90 	{
    93 	TInt err = TheFs.Connect();
   105 	TInt err = TheFs.Connect();
    94 	TEST2(err, KErrNone);
   106 	TEST2(err, KErrNone);
    95 
   107 
    96 	err = TheFs.MkDir(TheNonSecureDbName);
   108 	err = TheFs.MkDir(TheNonSecureDbName);
    97 	TEST(err == KErrNone || err == KErrAlreadyExists);
   109 	TEST(err == KErrNone || err == KErrAlreadyExists);
       
   110 
       
   111 	if(TheCmdLineParams.iLogFileName.Length() > 0)
       
   112 		{
       
   113 		err = TheLogFile.Replace(TheFs, TheCmdLineParams.iLogFileName, EFileRead | EFileWrite);
       
   114 		TEST2(err, KErrNone);
       
   115 		LogConfig(TheLogFile, TheCmdLineParams);
       
   116 		}
    98 	
   117 	
    99 	err = TheDbs.Connect();
   118 	err = TheDbs.Connect();
   100 	TEST2(err, KErrNone);
   119 	TEST2(err, KErrNone);
   101 	}
   120 	}
   102 
   121 
   155 		{
   174 		{
   156 		diffTicks = KMaxTUint32 + diffTicks + 1;
   175 		diffTicks = KMaxTUint32 + diffTicks + 1;
   157 		}
   176 		}
   158 	const TInt KMicroSecIn1Sec = 1000000;
   177 	const TInt KMicroSecIn1Sec = 1000000;
   159 	TInt32 us = (diffTicks * KMicroSecIn1Sec) / freq;
   178 	TInt32 us = (diffTicks * KMicroSecIn1Sec) / freq;
   160 	TheTest.Printf(_L("####Execution time: %d ms\r\n"), us / 1000);
   179 	TheTest.Printf(_L("%S: %d us\r\n"), &TheTestTitle, us);
   161 	}
   180 	if(TheCmdLineParams.iLogFileName.Length() > 0)
   162 	
   181 		{
   163 void PrintFileSize(const TDesC& aFileName)
   182 		TheLogLine.Format(_L("%S¬%d¬us\r\n"), &TheTestTitle, us);
   164 	{
   183 		TheLogLine8.Copy(TheLogLine);
   165 	RFile file;
   184 		(void)TheLogFile.Write(TheLogLine8);
   166 	TInt err = file.Open(TheFs, aFileName, EFileRead);
   185 		}
   167 	TEST2(err, KErrNone);
   186 	}
   168 	TInt size = 0;
   187 	
   169 	err = file.Size(size);
       
   170 	TEST2(err, KErrNone);
       
   171 	TheTest.Printf(_L("####FileSize: %d\r\n"), size);
       
   172 	file.Close();
       
   173 	}
       
   174 
       
   175 void PrintString(const TDesC& aStr)
       
   176 	{
       
   177 	TheTest.Printf(_L("Str begin~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n"));
       
   178 	TPtrC ptr(aStr);
       
   179 	while(ptr.Length() > 0)
       
   180 		{
       
   181 		TPtrC ptr2;
       
   182 		TInt len = Min(ptr.Length(), 60);
       
   183 		ptr2.Set(ptr.Left(len));
       
   184 		TheTest.Printf(_L("%S\r\n"), &ptr2);
       
   185 		ptr.Set(ptr.Mid(len));
       
   186 		}
       
   187 	TheTest.Printf(_L("Str end~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n"));
       
   188 	}
       
   189 
       
   190 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   188 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   191 ///////     DBMS SERVER performance tests
   189 ///////     DBMS SERVER performance tests
   192 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   190 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   193 
   191 
   194 //Creates aDb database schema.
   192 //Creates aDb database schema.
   396 	};
   394 	};
   397 	
   395 	
   398 //Executes SQL script
   396 //Executes SQL script
   399 void ExecuteSqlScript(RDbDatabase& aDb, const TDesC& aScriptFileName, TCompactDbOption aCompactDbOpt)
   397 void ExecuteSqlScript(RDbDatabase& aDb, const TDesC& aScriptFileName, TCompactDbOption aCompactDbOpt)
   400 	{
   398 	{
   401 	if(aCompactDbOpt == ECompactAfterCommit)
       
   402 		{
       
   403 		TheTest.Printf(_L("===Execute DB script: Compact after COMMIT\r\n"));	
       
   404 		}
       
   405 	else if(aCompactDbOpt == ECompactAtEnd)
       
   406 		{
       
   407 		TheTest.Printf(_L("===Execute DB script: Compact at end\r\n"));	
       
   408 		}
       
   409 	else
       
   410 		{
       
   411 		TheTest.Printf(_L("===Execute DB script: No compaction\r\n"));	
       
   412 		}
       
   413 	HBufC* fullDbScript = ReadSqlScript(aScriptFileName);
   399 	HBufC* fullDbScript = ReadSqlScript(aScriptFileName);
   414 	TUint32 start = User::FastCounter();
   400 	TUint32 start = User::FastCounter();
   415 	TPtrC ptr(fullDbScript->Des());
   401 	TPtrC ptr(fullDbScript->Des());
   416 	TInt stmtCnt = 0;
   402 	TInt stmtCnt = 0;
   417 	TInt err = aDb.Begin();
   403 	TInt err = aDb.Begin();
   423 		TInt rc = aDb.Execute(sql);
   409 		TInt rc = aDb.Execute(sql);
   424 		if(rc == KErrNoMemory)
   410 		if(rc == KErrNoMemory)
   425 			{
   411 			{
   426 			TheTest.Printf(_L("###ERROR 'Out of memory'! The test cannot be completed!\r\n"));
   412 			TheTest.Printf(_L("###ERROR 'Out of memory'! The test cannot be completed!\r\n"));
   427 			return;	
   413 			return;	
   428 			}
       
   429 		if(rc != 1)	
       
   430 			{
       
   431 			PrintString(sql);
       
   432 			}
   414 			}
   433 		TEST2(rc, 1);
   415 		TEST2(rc, 1);
   434 		if((stmtCnt % 200) == 0) //~16 transactions (~3270 statements total)
   416 		if((stmtCnt % 200) == 0) //~16 transactions (~3270 statements total)
   435 			{
   417 			{
   436 			err = aDb.Commit();	
   418 			err = aDb.Commit();	
   453 		TEST2(err, KErrNone);
   435 		TEST2(err, KErrNone);
   454 		}
   436 		}
   455 	TUint32 end = User::FastCounter();
   437 	TUint32 end = User::FastCounter();
   456 	PrintStats(start, end);
   438 	PrintStats(start, end);
   457 	delete fullDbScript;
   439 	delete fullDbScript;
   458 	TheTest.Printf(_L("###Processed records: %d\r\n"), stmtCnt);
       
   459 	}
   440 	}
   460 
   441 
   461 ///////////////////////////////////////////////////////////////////////////////////////
   442 ///////////////////////////////////////////////////////////////////////////////////////
   462 
   443 
   463 //"INSERT" test function
   444 //"INSERT" test function
   464 void InsertTest(TTestType aTestType, const TDesC& aDbFileName, TCompactDbOption aCompactDbOpt)
   445 void InsertTest(TTestType aTestType, const TDesC& aDbFileName, TCompactDbOption aCompactDbOpt)
   465 	{
   446 	{
   466 	TheTest.Printf(_L("\"Insert\" test\r\n"));
       
   467 	RDbDatabase db = TDbHelper::Open(aTestType, aDbFileName);
   447 	RDbDatabase db = TDbHelper::Open(aTestType, aDbFileName);
   468 	ExecuteSqlScript(db, KFillDbScript, aCompactDbOpt);
   448 	ExecuteSqlScript(db, KFillDbScript, aCompactDbOpt);
   469 	RDbTable tbl;
   449 	RDbTable tbl;
   470 	TInt err = tbl.Open(db, _L("CONTACTS"));
   450 	TInt err = tbl.Open(db, _L("CONTACTS"));
   471 	TEST2(err, KErrNone);
   451 	TEST2(err, KErrNone);
   478 	}
   458 	}
   479 
   459 
   480 //"UPDATE" test function
   460 //"UPDATE" test function
   481 void UpdateTest(TTestType aTestType, const TDesC& aDbFileName, const TDesC& aUpdateSql, TCompactDbOption aCompactDbOpt)
   461 void UpdateTest(TTestType aTestType, const TDesC& aDbFileName, const TDesC& aUpdateSql, TCompactDbOption aCompactDbOpt)
   482 	{
   462 	{
   483 	if(aCompactDbOpt == ECompactAfterEvery10Rec)
       
   484 		{
       
   485 		TheTest.Printf(_L("===Update: Compact after every 10 records\r\n"));	
       
   486 		}
       
   487 	else if(aCompactDbOpt == ECompactAfterEveryUpd)
       
   488 		{
       
   489 		TheTest.Printf(_L("===Update: Compact after every update\r\n"));	
       
   490 		}
       
   491 	else if(aCompactDbOpt == ECompactAtEnd)
       
   492 		{
       
   493 		TheTest.Printf(_L("===Update: Compact at end\r\n"));	
       
   494 		}
       
   495 	else
       
   496 		{
       
   497 		TheTest.Printf(_L("===Update: No compaction\r\n"));	
       
   498 		}
       
   499 	TheTest.Printf(_L("\"Update\" test\r\n"));
       
   500 	RDbDatabase db = TDbHelper::Open(aTestType, aDbFileName);
   463 	RDbDatabase db = TDbHelper::Open(aTestType, aDbFileName);
   501 
   464 
   502 	TUint32 start = User::FastCounter();
   465 	TUint32 start = User::FastCounter();
   503 	for(TInt id=1,updateOpCnt=0;id<=KTestTecordCount;++id,++updateOpCnt)
   466 	for(TInt id=1,updateOpCnt=0;id<=KTestTecordCount;++id,++updateOpCnt)
   504 		{
   467 		{
   505 		TBuf<200> sql;
   468 		TBuf<200> sql;
   506 		sql.Format(aUpdateSql, &KFirstName, id, &KLastName, id, &KCompanyName, id, id);
   469 		sql.Format(aUpdateSql, &KFirstName, id, &KLastName, id, &KCompanyName, id, id);
   507 		TInt rc = db.Execute(sql);
   470 		TInt rc = db.Execute(sql);
   508 		if(rc != 1)	
       
   509 			{
       
   510 			PrintString(sql);
       
   511 			}
       
   512 		TEST2(rc, 1);
   471 		TEST2(rc, 1);
   513 		if(aCompactDbOpt == ECompactAfterEveryUpd || (aCompactDbOpt == ECompactAfterEvery10Rec && (updateOpCnt % 10) == 0))
   472 		if(aCompactDbOpt == ECompactAfterEveryUpd || (aCompactDbOpt == ECompactAfterEvery10Rec && (updateOpCnt % 10) == 0))
   514 			{
   473 			{
   515 			TInt err = db.Compact();
   474 			TInt err = db.Compact();
   516 			TEST2(err, KErrNone);
   475 			TEST2(err, KErrNone);
   527 	}
   486 	}
   528 
   487 
   529 //"SELECT" test function
   488 //"SELECT" test function
   530 void SelectTestL(TTestType aTestType, const TDesC& aDbFileName, const TDesC& aSelectSql)
   489 void SelectTestL(TTestType aTestType, const TDesC& aDbFileName, const TDesC& aSelectSql)
   531 	{
   490 	{
   532 	TheTest.Printf(_L("\"Select\" test\r\n"));
       
   533 	RDbDatabase db = TDbHelper::Open(aTestType, aDbFileName);
   491 	RDbDatabase db = TDbHelper::Open(aTestType, aDbFileName);
   534 	TDbQuery query(aSelectSql);
   492 	TDbQuery query(aSelectSql);
   535 	RDbView view;
   493 	RDbView view;
   536 	TInt err = view.Prepare(db, query, RDbRowSet::EReadOnly);
   494 	TInt err = view.Prepare(db, query, RDbRowSet::EReadOnly);
   537 	TEST2(err, KErrNone);
   495 	TEST2(err, KErrNone);
   562 	}
   520 	}
   563 
   521 
   564 //"DELETE" test function
   522 //"DELETE" test function
   565 void DeleteTest(TTestType aTestType, const TDesC& aDbFileName, const TDesC& aDeleteSql, TCompactDbOption aCompactDbOpt)
   523 void DeleteTest(TTestType aTestType, const TDesC& aDbFileName, const TDesC& aDeleteSql, TCompactDbOption aCompactDbOpt)
   566 	{
   524 	{
   567 	if(aCompactDbOpt == ECompactAtEnd)
       
   568 		{
       
   569 		TheTest.Printf(_L("===Delete: Compact at end\r\n"));	
       
   570 		}
       
   571 	else
       
   572 		{
       
   573 		TheTest.Printf(_L("===Delete: No compaction\r\n"));	
       
   574 		}
       
   575 	TheTest.Printf(_L("\"Delete\" test\r\n"));
       
   576 	RDbDatabase db = TDbHelper::Open(aTestType, aDbFileName);
   525 	RDbDatabase db = TDbHelper::Open(aTestType, aDbFileName);
   577 	TUint32 start = User::FastCounter();
   526 	TUint32 start = User::FastCounter();
   578 	TInt rc = db.Execute(aDeleteSql);
   527 	TInt rc = db.Execute(aDeleteSql);
   579 	TEST(rc > 900);
   528 	TEST(rc > 900);
   580 	if(aCompactDbOpt == ECompactAtEnd)
   529 	if(aCompactDbOpt == ECompactAtEnd)
   607 	
   556 	
   608 	CFileMan* fm = CFileMan::NewL(TheFs);
   557 	CFileMan* fm = CFileMan::NewL(TheFs);
   609 	CleanupStack::PushL(fm);
   558 	CleanupStack::PushL(fm);
   610 
   559 
   611 	//==================================== CLIENT ==========================================================
   560 	//==================================== CLIENT ==========================================================
   612 	TheTest.Printf(_L("DBMS, insert, UTF16 SQL strings, non-secure db, client, no db compaction\r\n"));
   561 	TheTestTitle.Copy(_L("DBMS, insert, UTF16 SQL strings, non-secure db, client, no db compaction"));
   613 	TDbHelper::CreateL(TheNonSecureDbName);
   562 	TDbHelper::CreateL(TheNonSecureDbName);
   614 	InsertTest(EClientDbTest, TheNonSecureDbName, ENoCompaction);
   563 	InsertTest(EClientDbTest, TheNonSecureDbName, ENoCompaction);
   615 	PrintFileSize(TheNonSecureDbName);
   564 	
   616 	
   565 	TheTestTitle.Copy(_L("DBMS, insert, UTF16 SQL strings, non-secure db, client, db compaction at end"));
   617 	TheTest.Printf(_L("DBMS, insert, UTF16 SQL strings, non-secure db, client, db compaction at end\r\n"));
       
   618 	TDbHelper::CreateL(TheNonSecureDbName);
   566 	TDbHelper::CreateL(TheNonSecureDbName);
   619 	InsertTest(EClientDbTest, TheNonSecureDbName, ECompactAtEnd);
   567 	InsertTest(EClientDbTest, TheNonSecureDbName, ECompactAtEnd);
   620 	PrintFileSize(TheNonSecureDbName);
   568 	
   621 	
   569 	TheTestTitle.Copy(_L("DBMS, insert, UTF16 SQL strings, non-secure db, client, db compaction after commit"));
   622 	TheTest.Printf(_L("DBMS, insert, UTF16 SQL strings, non-secure db, client, db compaction after commit\r\n"));
       
   623 	TDbHelper::CreateL(TheNonSecureDbName);
   570 	TDbHelper::CreateL(TheNonSecureDbName);
   624 	InsertTest(EClientDbTest, TheNonSecureDbName, ECompactAfterCommit);
   571 	InsertTest(EClientDbTest, TheNonSecureDbName, ECompactAfterCommit);
   625 	PrintFileSize(TheNonSecureDbName);
       
   626 
   572 
   627 	TInt err = fm->Copy(TheNonSecureDbName, TheNonSecureDbName2);
   573 	TInt err = fm->Copy(TheNonSecureDbName, TheNonSecureDbName2);
   628 	TEST2(err, KErrNone);
   574 	TEST2(err, KErrNone);
   629 	
   575 	
   630 	TheTest.Printf(_L("DBMS, update, UTF16 SQL strings, non-secure db, client, no db compaction\r\n"));
   576 	TheTestTitle.Copy(_L("DBMS, update, UTF16 SQL strings, non-secure db, client, no db compaction"));
   631 	UpdateTest(EClientDbTest, TheNonSecureDbName, KUpdateSql(), ENoCompaction);
   577 	UpdateTest(EClientDbTest, TheNonSecureDbName, KUpdateSql(), ENoCompaction);
   632 	PrintFileSize(TheNonSecureDbName);
       
   633 	err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
   578 	err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
   634 	TEST2(err, KErrNone);
   579 	TEST2(err, KErrNone);
   635 	
   580 	
   636 	TheTest.Printf(_L("DBMS, update, UTF16 SQL strings, non-secure db, client, db compaction at end\r\n"));
   581 	TheTestTitle.Copy(_L("DBMS, update, UTF16 SQL strings, non-secure db, client, db compaction at end"));
   637 	UpdateTest(EClientDbTest, TheNonSecureDbName, KUpdateSql(), ECompactAtEnd);
   582 	UpdateTest(EClientDbTest, TheNonSecureDbName, KUpdateSql(), ECompactAtEnd);
   638 	PrintFileSize(TheNonSecureDbName);
       
   639 	err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
   583 	err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
   640 	TEST2(err, KErrNone);
   584 	TEST2(err, KErrNone);
   641 
   585 
   642 	TheTest.Printf(_L("DBMS, update, UTF16 SQL strings, non-secure db, client, db compaction after every 10 records\r\n"));
   586 	TheTestTitle.Copy(_L("DBMS, update, UTF16 SQL strings, non-secure db, client, db compaction after every 10 records"));
   643 	UpdateTest(EClientDbTest, TheNonSecureDbName, KUpdateSql(), ECompactAfterEvery10Rec);
   587 	UpdateTest(EClientDbTest, TheNonSecureDbName, KUpdateSql(), ECompactAfterEvery10Rec);
   644 	PrintFileSize(TheNonSecureDbName);
   588 	
   645 //L	err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
   589 	TheTestTitle.Copy(_L("DBMS, select, UTF16 SQL strings, non-secure db, client"));
   646 //L	TEST2(err, KErrNone);
       
   647 	
       
   648 //L	TheTest.Printf(_L("DBMS, update, UTF16 SQL strings, non-secure db, client, db compaction after every update\r\n"));
       
   649 //L	UpdateTest(EClientDbTest, TheNonSecureDbName, KUpdateSql(), ECompactAfterEveryUpd);
       
   650 //L	PrintFileSize(TheNonSecureDbName);
       
   651 	
       
   652 	TheTest.Printf(_L("DBMS, select, UTF16 SQL strings, non-secure db, client\r\n"));
       
   653 	SelectTestL(EClientDbTest, TheNonSecureDbName, KSelectSql());
   590 	SelectTestL(EClientDbTest, TheNonSecureDbName, KSelectSql());
   654 
   591 
   655 	TheTest.Printf(_L("DBMS, delete, UTF16 SQL strings, non-secure db, client\r\n"));
   592 	TheTestTitle.Copy(_L("DBMS, delete, UTF16 SQL strings, non-secure db, client"));
   656 	DeleteTest(EClientDbTest, TheNonSecureDbName, KDeleteSql(), ECompactAtEnd);
   593 	DeleteTest(EClientDbTest, TheNonSecureDbName, KDeleteSql(), ECompactAtEnd);
   657 	PrintFileSize(TheNonSecureDbName);
       
   658 
   594 
   659 	//==================================== SERVER ==========================================================
   595 	//==================================== SERVER ==========================================================
   660 
   596 
   661 	TheTest.Printf(_L("DBMS, insert, UTF16 SQL strings, non-secure db, server, no db compaction\r\n"));
   597 	TheTestTitle.Copy(_L("DBMS, insert, UTF16 SQL strings, non-secure db, server, no db compaction"));
   662 	TDbHelper::CreateL(TheNonSecureDbName);
   598 	TDbHelper::CreateL(TheNonSecureDbName);
   663 	InsertTest(EServerDbTest, TheNonSecureDbName, ENoCompaction);
   599 	InsertTest(EServerDbTest, TheNonSecureDbName, ENoCompaction);
   664 	PrintFileSize(TheNonSecureDbName);
   600 	
   665 	
   601 	TheTestTitle.Copy(_L("DBMS, insert, UTF16 SQL strings, non-secure db, server, db compaction at end"));
   666 	TheTest.Printf(_L("DBMS, insert, UTF16 SQL strings, non-secure db, server, db compaction at end\r\n"));
       
   667 	TDbHelper::CreateL(TheNonSecureDbName);
   602 	TDbHelper::CreateL(TheNonSecureDbName);
   668 	InsertTest(EServerDbTest, TheNonSecureDbName, ECompactAtEnd);
   603 	InsertTest(EServerDbTest, TheNonSecureDbName, ECompactAtEnd);
   669 	PrintFileSize(TheNonSecureDbName);
   604 
   670 
   605 	TheTestTitle.Copy(_L("DBMS, insert, UTF16 SQL strings, non-secure db, server, db compaction after commit"));
   671 	TheTest.Printf(_L("DBMS, insert, UTF16 SQL strings, non-secure db, server, db compaction after commit\r\n"));
       
   672 	TDbHelper::CreateL(TheNonSecureDbName);
   606 	TDbHelper::CreateL(TheNonSecureDbName);
   673 	InsertTest(EServerDbTest, TheNonSecureDbName, ECompactAfterCommit);
   607 	InsertTest(EServerDbTest, TheNonSecureDbName, ECompactAfterCommit);
   674 	PrintFileSize(TheNonSecureDbName);
       
   675 
   608 
   676 	err = fm->Copy(TheNonSecureDbName, TheNonSecureDbName2);
   609 	err = fm->Copy(TheNonSecureDbName, TheNonSecureDbName2);
   677 	TEST2(err, KErrNone);
   610 	TEST2(err, KErrNone);
   678 
   611 
   679 	TheTest.Printf(_L("DBMS, update, UTF16 SQL strings, non-secure db, server, no db compaction\r\n"));
   612 	TheTestTitle.Copy(_L("DBMS, update, UTF16 SQL strings, non-secure db, server, no db compaction"));
   680 	UpdateTest(EServerDbTest, TheNonSecureDbName, KUpdateSql(), ENoCompaction);
   613 	UpdateTest(EServerDbTest, TheNonSecureDbName, KUpdateSql(), ENoCompaction);
   681 	PrintFileSize(TheNonSecureDbName);
       
   682 	err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
   614 	err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
   683 	TEST2(err, KErrNone);
   615 	TEST2(err, KErrNone);
   684 	
   616 	
   685 	TheTest.Printf(_L("DBMS, update, UTF16 SQL strings, non-secure db, server, db compaction at end\r\n"));
   617 	TheTestTitle.Copy(_L("DBMS, update, UTF16 SQL strings, non-secure db, server, db compaction at end"));
   686 	UpdateTest(EServerDbTest, TheNonSecureDbName, KUpdateSql(), ECompactAtEnd);
   618 	UpdateTest(EServerDbTest, TheNonSecureDbName, KUpdateSql(), ECompactAtEnd);
   687 	PrintFileSize(TheNonSecureDbName);
       
   688 	err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
   619 	err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
   689 	TEST2(err, KErrNone);
   620 	TEST2(err, KErrNone);
   690 
   621 
   691 	TheTest.Printf(_L("DBMS, update, UTF16 SQL strings, non-secure db, server, db compaction after every 10 records\r\n"));
   622 	TheTestTitle.Copy(_L("DBMS, update, UTF16 SQL strings, non-secure db, server, db compaction after every 10 records"));
   692 	UpdateTest(EServerDbTest, TheNonSecureDbName, KUpdateSql(), ECompactAfterEvery10Rec);
   623 	UpdateTest(EServerDbTest, TheNonSecureDbName, KUpdateSql(), ECompactAfterEvery10Rec);
   693 	PrintFileSize(TheNonSecureDbName);
   624 	
   694 //L	err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
   625 	TheTestTitle.Copy(_L("DBMS, select, UTF16 SQL strings, non-secure db, server"));
   695 //L	TEST2(err, KErrNone);
       
   696 
       
   697 //L	TheTest.Printf(_L("DBMS, update, UTF16 SQL strings, non-secure db, server, db compaction after every update\r\n"));
       
   698 //L	UpdateTest(EServerDbTest, TheNonSecureDbName, KUpdateSql(), ECompactAfterEveryUpd);
       
   699 //L	PrintFileSize(TheNonSecureDbName);
       
   700 	
       
   701 	TheTest.Printf(_L("DBMS, select, UTF16 SQL strings, non-secure db, server\r\n"));
       
   702 	SelectTestL(EServerDbTest, TheNonSecureDbName, KSelectSql());
   626 	SelectTestL(EServerDbTest, TheNonSecureDbName, KSelectSql());
   703 
   627 
   704 	TheTest.Printf(_L("DBMS, delete, UTF16 SQL strings, non-secure db, server\r\n"));
   628 	TheTestTitle.Copy(_L("DBMS, delete, UTF16 SQL strings, non-secure db, server"));
   705 	DeleteTest(EServerDbTest, TheNonSecureDbName, KDeleteSql(), ECompactAtEnd);
   629 	DeleteTest(EServerDbTest, TheNonSecureDbName, KDeleteSql(), ECompactAtEnd);
   706 	PrintFileSize(TheNonSecureDbName);
       
   707 	
   630 	
   708 	//======================================================================================================
   631 	//======================================================================================================
   709 	CleanupStack::PopAndDestroy(fm);
   632 	CleanupStack::PopAndDestroy(fm);
   710 	}
   633 	}
   711 
   634 
   712 //Usage: "t_dbperf1 [<drive letter>:]"
       
   713 
       
   714 TInt E32Main()
   635 TInt E32Main()
   715 	{
   636 	{
   716 	TheTest.Title();
   637 	TheTest.Title();
   717 	
   638 	
   718 	CTrapCleanup* tc = CTrapCleanup::New();
   639 	CTrapCleanup* tc = CTrapCleanup::New();
   719 
   640 
   720 	//Construct test database file names, using the passed as an optional argument drive letter 
   641 	GetCmdLineParams(TheTest, _L("t_dbperf1"), TheCmdLineParams);
   721 	TFileName fname;
       
   722 	TParse parse;
       
   723 	User::CommandLine(fname);
       
   724 	
       
   725 	_LIT(KNonSecureDbName, "c:\\test\\t_dbperf1_1.db");
   642 	_LIT(KNonSecureDbName, "c:\\test\\t_dbperf1_1.db");
   726 	parse.Set(fname, &KNonSecureDbName, 0);
   643 	PrepareDbName(KNonSecureDbName, TheCmdLineParams.iDriveName, TheNonSecureDbName);
   727 	const TDesC& dbFilePath1 = parse.FullName();
       
   728 	TheNonSecureDbName.Copy(dbFilePath1);
       
   729 
       
   730 	_LIT(KNonSecureDbName2, "c:\\test\\t_dbperf1_2.db");
   644 	_LIT(KNonSecureDbName2, "c:\\test\\t_dbperf1_2.db");
   731 	parse.Set(fname, &KNonSecureDbName2, 0);
   645 	PrepareDbName(KNonSecureDbName2, TheCmdLineParams.iDriveName, TheNonSecureDbName2);
   732 	const TDesC& dbFilePath2 = parse.FullName();
   646 	TheTest.Printf(_L("==Databases: %S, %S\r\n"), &TheNonSecureDbName, &TheNonSecureDbName2); 
   733 	TheNonSecureDbName2.Copy(dbFilePath2);
       
   734 	
   647 	
   735 	__UHEAP_MARK;
   648 	__UHEAP_MARK;
   736 	
   649 	
   737 	TestEnvInit();
   650 	TestEnvInit();
   738 	TRAPD(err, DoTestsL());
   651 	TRAPD(err, DoTestsL());
   739 	TestEnvDestroy();
   652 	TestEnvDestroy();
   740 	TEST2(err, KErrNone);
   653 	TEST2(err, KErrNone);
   741 	
   654 	
   742 	__UHEAP_MARKEND;
   655 	__UHEAP_MARKEND;
       
   656 
       
   657 	User::Heap().Check();
   743 	
   658 	
   744 	TheTest.End();
   659 	TheTest.End();
   745 	TheTest.Close();
   660 	TheTest.Close();
   746 	
   661 	
   747 	delete tc;
   662 	delete tc;
   748 
   663 
   749 	User::Heap().Check();
       
   750 	return KErrNone;
   664 	return KErrNone;
   751 	}
   665 	}