sl@0: // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: static RTest TheTest(_L("t_dbperf2")); sl@0: static CTrapCleanup* TheTrapCleanup; sl@0: static RFs TheFs; sl@0: static RDbs TheDbs; sl@0: static RDbNamedDatabase TheDatabase; sl@0: static RDbRowSet TheRowSet; sl@0: static RFile TheTestFile; sl@0: static TFileName TheDatabaseFileName; sl@0: static TFileName TheLogFileName; sl@0: static TFileName TheTestFileName; sl@0: static TParse TheParse; sl@0: sl@0: #define COUNT_OF(array) (sizeof(array)/sizeof(array[0])) sl@0: sl@0: const TInt KTestRecordCount = 400; sl@0: sl@0: const TInt KTextColSize = 200;//Change KCreateTestTableSql string too! sl@0: sl@0: _LIT(KCreateTestTableSql, "CREATE TABLE A(I1 INTEGER, I2 DOUBLE, I3 VARCHAR(200))"); sl@0: _LIT(KCreateIndexSql, "CREATE UNIQUE INDEX IDX ON A(I1)"); sl@0: sl@0: const TInt KColSize2 = 500; sl@0: _LIT(KCreateTestTableSql2, "CREATE TABLE A(I1 INTEGER, I2 LONG VARCHAR, I3 LONG VARBINARY)"); sl@0: sl@0: const TChar KBufChar('O'); sl@0: TBuf8 TheBinRndData; sl@0: TBuf16 TheTextRndData; sl@0: sl@0: ////////////////////////////////////////////////////// sl@0: sl@0: static TInt TheCounterFreq = -10000000; sl@0: const TInt KMicroSecIn1Sec = 1000000; sl@0: sl@0: TUint32 CalcTickDiff(TUint32 aStartTicks, TUint32 aEndTicks) sl@0: { sl@0: TInt64 diffTicks = (TInt64)aEndTicks - (TInt64)aStartTicks; sl@0: if(diffTicks < 0) sl@0: { sl@0: diffTicks = KMaxTUint32 + diffTicks + 1; sl@0: } sl@0: return (TUint32)diffTicks; sl@0: } sl@0: sl@0: //Prints aFastCount parameter (converted to us) sl@0: void PrintFcDiffAsUs(const TDesC& aFormatStr, TUint32 aFastCount) sl@0: { sl@0: double v = ((double)aFastCount * KMicroSecIn1Sec) / (double)TheCounterFreq; sl@0: TInt v2 = (TInt)v; sl@0: TheTest.Printf(aFormatStr, v2); sl@0: } sl@0: sl@0: //Prints aFastCount parameter (converted to us) and the records count sl@0: void PrintFcDiffAsUs2(const TDesC& aFormatStr, TInt aRecCnt, TUint32 aFastCount) sl@0: { sl@0: double v = ((double)aFastCount * KMicroSecIn1Sec) / (double)TheCounterFreq; sl@0: TInt v2 = (TInt)v; sl@0: TheTest.Printf(aFormatStr, aRecCnt, v2); sl@0: } sl@0: sl@0: ////////////////////////////////////////////////////// sl@0: sl@0: enum TRowSetType {EViewRowSet, ETableRowSet}; sl@0: const TRowSetType KRowSetTypes[] = {EViewRowSet/*, ETableRowSet*/}; //Excluding ETableRowSet means that the test requires less time. sl@0: const TPtrC KRowSetTypeStr[] = {_L("RDbView.")/*, _L("RDbTable.")*/};//The coverage is not affected that much. sl@0: sl@0: ////////////////////////////////////////////////////// sl@0: sl@0: const RDbRowSet::TAccess KAccessModes[] = {RDbRowSet::EInsertOnly, RDbRowSet::EUpdatable}; sl@0: const TPtrC KAccessModeStr[] = {_L("Insert only."), _L("Updatable.")}; sl@0: sl@0: ////////////////////////////////////////////////////// sl@0: sl@0: enum TUpdDirection {EUpdBackward, EUpdForward}; sl@0: const TUpdDirection KUpdDirectionTypes[] = {EUpdBackward, EUpdForward}; sl@0: const TPtrC KUpdDirectionTypeStr[] = {_L("Backward."), _L("Forward.")}; sl@0: sl@0: ////////////////////////////////////////////////////// sl@0: sl@0: enum TCommitRecCnt {ECommit_1_Rec = 1, ECommit_Cnt_Rec = 20, ECommit_All_Rec = KTestRecordCount}; sl@0: const TCommitRecCnt KCommitTypes[] = {ECommit_1_Rec, ECommit_Cnt_Rec, ECommit_All_Rec}; sl@0: const TPtrC KCommitTypeStr[] = {_L("Commit after 1 op."), _L("Commit after 20 ops."), _L("Commit at end.")}; sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: //Delete "aFullName" file. sl@0: static void DeleteFile(const TDesC& aFullName) sl@0: { sl@0: RFs fsSession; sl@0: TInt err = fsSession.Connect(); sl@0: if(err == KErrNone) sl@0: { sl@0: TEntry entry; sl@0: if(fsSession.Entry(aFullName, entry) == KErrNone) sl@0: { sl@0: err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly); sl@0: if(err != KErrNone) sl@0: { sl@0: TheTest.Printf(_L("Error %d changing \"%S\" file attributes.\n"), err, &aFullName); sl@0: } sl@0: err = fsSession.Delete(aFullName); sl@0: if(err != KErrNone) sl@0: { sl@0: TheTest.Printf(_L("Error %d deleting \"%S\" file.\n"), err, &aFullName); sl@0: } sl@0: } sl@0: fsSession.Close(); sl@0: } sl@0: else sl@0: { sl@0: TheTest.Printf(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName); sl@0: } sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: static void CloseAll() sl@0: { sl@0: TheRowSet.Close(); sl@0: TheDatabase.Close(); sl@0: TheDbs.Close(); sl@0: TheTestFile.Close(); sl@0: TheFs.Close(); sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: //Tests macros and functions. sl@0: //If (!aValue) then the test will be panicked, the test data files will be deleted. sl@0: static void Check(TInt aValue, TInt aLine) sl@0: { sl@0: if(!aValue) sl@0: { sl@0: CloseAll(); sl@0: DeleteFile(TheDatabaseFileName); sl@0: DeleteFile(TheTestFileName); sl@0: TheTest(EFalse, aLine); sl@0: } sl@0: } sl@0: //If (aValue != aExpected) then the test will be panicked, the test data files will be deleted. sl@0: static void Check(TInt aValue, TInt aExpected, TInt aLine) sl@0: { sl@0: if(aValue != aExpected) sl@0: { sl@0: TheTest.Printf(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); sl@0: CloseAll(); sl@0: DeleteFile(TheDatabaseFileName); sl@0: DeleteFile(TheTestFileName); sl@0: TheTest(EFalse, aLine); sl@0: } sl@0: } sl@0: //Use these to test conditions. sl@0: #define TEST(arg) ::Check((arg), __LINE__) sl@0: #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: void PrintFileSize() sl@0: { sl@0: RDbDatabase::TSize s = TheDatabase.Size(); sl@0: TheTest.Printf(_L("####FileSize: %d\r\n"), s.iSize); sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: void DbRowSetInsertTestL(TRowSetType aRowSetType, RDbRowSet::TAccess aAccessMode, TCommitRecCnt aCommitRecCnt) sl@0: { sl@0: TBuf textColVal; sl@0: for(TInt ii=23000;ii<(23000+KTextColSize);++ii) sl@0: { sl@0: textColVal.Append(TChar(ii)); sl@0: } sl@0: for(TInt compaction=0;compaction<2;++compaction) sl@0: { sl@0: TheTest.Printf(compaction ? _L("Compaction:Yes.\r\n") : _L("Compaction:No.\r\n")); sl@0: TheRowSet.Close(); sl@0: TInt err; sl@0: err = TheDatabase.Execute(_L("DELETE FROM A")); sl@0: TEST(err >= 0); sl@0: TUint32 fc = User::FastCounter(); sl@0: if(aRowSetType == EViewRowSet) sl@0: { sl@0: RDbView view; sl@0: err = view.Prepare(TheDatabase, _L("SELECT * FROM A"), aAccessMode); sl@0: TEST2(err, KErrNone); sl@0: err = view.EvaluateAll(); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet = view; sl@0: } sl@0: else sl@0: { sl@0: RDbTable tbl; sl@0: err = tbl.Open(TheDatabase, _L("A"), aAccessMode); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet = tbl; sl@0: } sl@0: TUint32 prepFc = CalcTickDiff(fc, User::FastCounter()); sl@0: TUint32 insFc = 0; sl@0: TUint32 setcolFc = 0; sl@0: TUint32 putFc = 0; sl@0: TUint32 commitFc = 0; sl@0: TUint32 totalFc = 0; sl@0: fc = User::FastCounter(); sl@0: for(TInt i=0,count=0;i textColVal; sl@0: for(TInt ii=33000;ii<(33000+KTextColSize);++ii) sl@0: { sl@0: textColVal.Append(TChar(ii)); sl@0: } sl@0: sl@0: for(TInt compaction=0;compaction<2;++compaction) sl@0: { sl@0: TheTest.Printf(compaction ? _L("Compaction:Yes.\r\n") : _L("Compaction:No.\r\n")); sl@0: TheRowSet.Close(); sl@0: TInt err; sl@0: TUint32 fc = User::FastCounter(); sl@0: if(aRowSetType == EViewRowSet) sl@0: { sl@0: RDbView view; sl@0: err = view.Prepare(TheDatabase, _L("SELECT * FROM A WHERE I1 >= 0 AND I1 <= 1000000"), RDbRowSet::EUpdatable); sl@0: TEST2(err, KErrNone); sl@0: err = view.EvaluateAll(); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet = view; sl@0: } sl@0: else sl@0: { sl@0: RDbTable tbl; sl@0: err = tbl.Open(TheDatabase, _L("A"), RDbRowSet::EUpdatable); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet = tbl; sl@0: } sl@0: TInt cnt = TheRowSet.CountL(); sl@0: TEST2(cnt, KTestRecordCount); sl@0: TUint32 prepFc = CalcTickDiff(fc, User::FastCounter()); sl@0: TUint32 insFc = 0; sl@0: TUint32 setcolFc = 0; sl@0: TUint32 putFc = 0; sl@0: TUint32 commitFc = 0; sl@0: TUint32 totalFc = 0; sl@0: fc = User::FastCounter(); sl@0: for(TInt i=0,count=0;i textColVal; sl@0: for(TInt ii=23000;ii<(23000+KTextColSize);++ii) sl@0: { sl@0: textColVal.Append(TChar(ii)); sl@0: } sl@0: err = TheDatabase.Begin(); sl@0: TEST2(err, KErrNone); sl@0: for(TInt i=0;i sql; sl@0: sql.Format(_L("INSERT INTO A(I1,I2,I3) VALUES(%d,%d,'%S')"), i, i + 100000, &textColVal); sl@0: err = TheDatabase.Execute(sql); sl@0: TEST2(err, 1); sl@0: } sl@0: err = TheDatabase.Commit(); sl@0: TEST2(err, KErrNone); sl@0: } sl@0: sl@0: void DestroyDatabase() sl@0: { sl@0: TheRowSet.Close(); sl@0: TheDatabase.Close(); sl@0: TheDbs.Close(); sl@0: TInt err = TheFs.Delete(TheDatabaseFileName); sl@0: TEST2(err, KErrNone); sl@0: } sl@0: sl@0: void GetFastCounterFrequency() sl@0: { sl@0: TheTest.Start(_L("Get fast counter frequency")); sl@0: TEST2(HAL::Get(HAL::EFastCounterFrequency, TheCounterFreq), KErrNone); sl@0: TheTest.Printf(_L("Counter frequency=%d\r\n"), TheCounterFreq); sl@0: } sl@0: sl@0: void FileBlockSizeTestsL() sl@0: { sl@0: TheTest.Next(_L("File Block Size test")); sl@0: sl@0: const TInt KBlockSizeLow = 64, KBlockSizeHigh = 1024 * 64; sl@0: for(TInt blockSize=KBlockSizeLow;blockSize<=KBlockSizeHigh;blockSize*=2) sl@0: { sl@0: for(TInt addSize=-4;addSize<=4;addSize+=4) sl@0: { sl@0: TInt currBlockSize = blockSize + addSize; sl@0: TBuf<100> title; sl@0: title.Copy(_L("File block size ")); sl@0: title.AppendNum((TInt64)currBlockSize); sl@0: title.Append(_L(" bytes")); sl@0: TheTest.Printf(title); sl@0: sl@0: HBufC8* data = HBufC8::New(currBlockSize); sl@0: TEST(data != NULL); sl@0: TPtr8 dataPtr = data->Des(); sl@0: dataPtr.SetLength(currBlockSize); sl@0: sl@0: TInt err = TheTestFile.Replace(TheFs, TheTestFileName, EFileRead | EFileWrite); sl@0: TEST2(err, KErrNone); sl@0: err = TheTestFile.Write(dataPtr); sl@0: TEST2(err, KErrNone); sl@0: err = TheTestFile.Flush(); sl@0: TEST2(err, KErrNone); sl@0: TUint32 fc = User::FastCounter(); sl@0: err = TheTestFile.Write(0, dataPtr); sl@0: fc = CalcTickDiff(fc, User::FastCounter()); sl@0: PrintFcDiffAsUs(_L("###Time=%d us\r\n"), fc); sl@0: TEST2(err, KErrNone); sl@0: TheTestFile.Close(); sl@0: sl@0: delete data; sl@0: } sl@0: } sl@0: DeleteFile(TheTestFileName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-UT-3310 sl@0: @SYMTestCaseDesc DBMS, RDbView performance tests. sl@0: @SYMTestPriority High sl@0: @SYMTestActions The test creates and fills a test table with integer, real and text column. Then sl@0: executes 3 test subcases: sl@0: - updates the integer column only in all records, using "SELECT I1,I2,I3" cursor; sl@0: - updates the text column only in all records, using "SELECT I1,I2,I3" cursor; sl@0: - updates all columns in all records, using "SELECT I1,I2,I3" cursor; sl@0: The execution times are printed out. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ7141 sl@0: */ sl@0: void RecordLenTestL() sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-UT-3310 Record length test - create database")); sl@0: CreateAndFillDatabase(); sl@0: //////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: TheTest.Printf(_L("Record length test - update the integer column only")); sl@0: TUint32 fc = User::FastCounter(); sl@0: RDbView view; sl@0: TInt err = view.Prepare(TheDatabase, _L("SELECT * FROM A")); sl@0: TEST2(err, KErrNone); sl@0: err = view.EvaluateAll(); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet = view; sl@0: err = TheDatabase.Begin(); sl@0: TEST2(err, KErrNone); sl@0: TInt recCnt = 0; sl@0: TheRowSet.FirstL(); sl@0: do sl@0: { sl@0: TheRowSet.UpdateL(); sl@0: TheRowSet.SetColL(1, 60000 + recCnt); sl@0: TheRowSet.PutL(); sl@0: ++recCnt; sl@0: } sl@0: while(TheRowSet.NextL()); sl@0: TEST2(recCnt, KTestRecordCount); sl@0: err = TheDatabase.Commit(); sl@0: TEST2(err, KErrNone); sl@0: PrintFcDiffAsUs(_L("###Time=%d us\r\n"), CalcTickDiff(fc, User::FastCounter())); sl@0: TheRowSet.Close(); sl@0: //////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: TheTest.Printf(_L("Record length test - update the text column only")); sl@0: fc = User::FastCounter(); sl@0: err = view.Prepare(TheDatabase, _L("SELECT * FROM A")); sl@0: TEST2(err, KErrNone); sl@0: err = view.EvaluateAll(); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet = view; sl@0: err = TheDatabase.Begin(); sl@0: TEST2(err, KErrNone); sl@0: recCnt = 0; sl@0: TheRowSet.FirstL(); sl@0: do sl@0: { sl@0: TheRowSet.UpdateL(); sl@0: TheRowSet.SetColL(3, _L("0123456789")); sl@0: TheRowSet.PutL(); sl@0: ++recCnt; sl@0: } sl@0: while(TheRowSet.NextL()); sl@0: TEST2(recCnt, KTestRecordCount); sl@0: err = TheDatabase.Commit(); sl@0: TEST2(err, KErrNone); sl@0: PrintFcDiffAsUs(_L("###Time=%d us\r\n"), CalcTickDiff(fc, User::FastCounter())); sl@0: TheRowSet.Close(); sl@0: //////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: TheTest.Printf(_L("Record length test - update all columns")); sl@0: fc = User::FastCounter(); sl@0: err = view.Prepare(TheDatabase, _L("SELECT * FROM A")); sl@0: TEST2(err, KErrNone); sl@0: err = view.EvaluateAll(); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet = view; sl@0: err = TheDatabase.Begin(); sl@0: TEST2(err, KErrNone); sl@0: recCnt = 0; sl@0: TheRowSet.FirstL(); sl@0: do sl@0: { sl@0: TheRowSet.UpdateL(); sl@0: TheRowSet.SetColL(1, 34567 - recCnt); sl@0: TheRowSet.SetColL(2, 888.111); sl@0: TheRowSet.SetColL(3, _L("QWETYUIOPASDF")); sl@0: TheRowSet.PutL(); sl@0: ++recCnt; sl@0: } sl@0: while(TheRowSet.NextL()); sl@0: TEST2(recCnt, KTestRecordCount); sl@0: err = TheDatabase.Commit(); sl@0: TEST2(err, KErrNone); sl@0: PrintFcDiffAsUs(_L("###Time=%d ms\r\n"), CalcTickDiff(fc, User::FastCounter())); sl@0: //////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: DestroyDatabase();//This will destroy TheRowSet object too. sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-UT-3311 sl@0: @SYMTestCaseDesc DBMS, RDbView performance tests. sl@0: @SYMTestPriority High sl@0: @SYMTestActions The test measures the time used by insert-only or updatable cursor to: sl@0: - insert certain amount of records, comitting after each insert; sl@0: - insert certain amount of records, comitting after 20 inserts; sl@0: - insert certain amount of records, comitting at the end; sl@0: All cases repeated with and without compaction (except the first one). sl@0: The execution times are printed out. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ7141 sl@0: */ sl@0: void InsertTestsL() sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-UT-3311 RDbView \"insert\" performance tests")); sl@0: for(TInt i1=0;i1 title; sl@0: title.Copy(_L("Insert.")); sl@0: title.Append(KRowSetTypeStr[i1]); sl@0: title.Append(KAccessModeStr[i2]); sl@0: title.Append(KCommitTypeStr[i3]); sl@0: TheTest.Printf(title); sl@0: DbRowSetInsertTestL(KRowSetTypes[i1], KAccessModes[i2], KCommitTypes[i3]); sl@0: DestroyDatabase(); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-UT-3312 sl@0: @SYMTestCaseDesc DBMS, RDbView performance tests. sl@0: @SYMTestPriority High sl@0: @SYMTestActions The test measures the time used by updatable cursor to: sl@0: - update (moving forward/backward) certain amount of records, comitting after each update; sl@0: - update (moving forward/backward) certain amount of records, comitting after 20 update; sl@0: - update (moving forward/backward) certain amount of records, comitting at the end; sl@0: All cases repeated with and without compaction (except the first one). sl@0: The execution times are printed out. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ7141 sl@0: */ sl@0: void UpdateTestsL() sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-UT-3312 RDbView \"update\" performance tests")); sl@0: for(TInt i1=0;i1 title; sl@0: title.Copy(_L("Update.")); sl@0: title.Append(KRowSetTypeStr[i1]); sl@0: title.Append(KUpdDirectionTypeStr[i2]); sl@0: title.Append(KCommitTypeStr[i3]); sl@0: TheTest.Printf(title); sl@0: DbRowSetUpdateTestL(KRowSetTypes[i1], KUpdDirectionTypes[i2], KCommitTypes[i3]); sl@0: DestroyDatabase(); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-UT-3313 sl@0: @SYMTestCaseDesc DBMS, RDbDatabase::Execute() performance tests. sl@0: @SYMTestPriority High sl@0: @SYMTestActions The test measures the time used by RDbDatabase::Execute() to: sl@0: - insert certain amount of records, comitting after each insert; sl@0: - insert certain amount of records, comitting after 20 inserts; sl@0: - insert certain amount of records, comitting at the end; sl@0: All cases repeated with and without compaction (except the first one). sl@0: The execution times are printed out. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ7141 sl@0: */ sl@0: void DbInsertTestsL() sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-UT-3313 RDbDatabase::Execute() \"insert\" performance tests")); sl@0: TBuf textColVal; sl@0: for(TInt ii=23000;ii<(23000+KTextColSize);++ii) sl@0: { sl@0: textColVal.Append(TChar(ii)); sl@0: } sl@0: for(TInt compaction=0;compaction<2;++compaction) sl@0: { sl@0: for(TInt i3=0;i3 title; sl@0: title.Copy(_L("RDbDatabase::Execute().Insert.")); sl@0: title.Append(KCommitTypeStr[i3]); sl@0: title.Append(compaction ? _L("Compaction:Yes.") : _L("Compaction:No.")); sl@0: TheTest.Printf(title); sl@0: TInt count = 0, err = KErrNone; sl@0: TUint32 fc = User::FastCounter(); sl@0: for(TInt i=0;i sql; sl@0: sql.Format(_L("INSERT INTO A(I1,I2,I3) VALUES(%d,%d,'%S')"), i, i + 100000, &textColVal); sl@0: err = TheDatabase.Execute(sql); sl@0: TEST2(err, 1); sl@0: if(KCommitTypes[i3] != ECommit_1_Rec && ++count == KCommitTypes[i3]) sl@0: { sl@0: count = 0; sl@0: err = TheDatabase.Commit(); sl@0: TEST2(err, KErrNone); sl@0: if(compaction) sl@0: { sl@0: err = TheDatabase.Compact(); sl@0: TEST2(err, KErrNone); sl@0: } sl@0: } sl@0: } sl@0: PrintFcDiffAsUs(_L("###RDbDatabase::Execute(), Time=%d us\r\n"), CalcTickDiff(fc, User::FastCounter())); sl@0: PrintFileSize(); sl@0: DestroyDatabase(); sl@0: } sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-UT-3314 sl@0: @SYMTestCaseDesc DBMS, RDbDatabase::Execute() performance tests. sl@0: @SYMTestPriority High sl@0: @SYMTestActions The test measures the time used by RDbDatabase::Execute() to: sl@0: - update certain amount of records, comitting after each update; sl@0: - update certain amount of records, comitting after 20 updates; sl@0: - update certain amount of records, comitting at the end; sl@0: All cases repeated with and without compaction (except the first one). sl@0: The execution times are printed out. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ7141 sl@0: */ sl@0: void DbUpdateTestsL() sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-UT-3314 RDbDatabase::Execute() \"update\" performance tests")); sl@0: TBuf textColVal; sl@0: for(TInt ii=43000;ii<(43000+KTextColSize);++ii) sl@0: { sl@0: textColVal.Append(TChar(ii)); sl@0: } sl@0: for(TInt compaction=0;compaction<2;++compaction) sl@0: { sl@0: for(TInt i3=0;i3 title; sl@0: title.Copy(_L("RDbDatabase::Execute().Update.")); sl@0: title.Append(KCommitTypeStr[i3]); sl@0: title.Append(compaction ? _L("Compaction:Yes.") : _L("Compaction:No.")); sl@0: TheTest.Printf(title); sl@0: TInt count = 0, err = KErrNone; sl@0: TUint32 fc = User::FastCounter(); sl@0: for(TInt i=0;i sql; sl@0: sql.Format(_L("UPDATE A SET I2=%d,I3='%S' WHERE I1=%d"), i + 556622, &textColVal, i); sl@0: err = TheDatabase.Execute(sql); sl@0: TEST2(err, 1); sl@0: if(KCommitTypes[i3] != ECommit_1_Rec && ++count == KCommitTypes[i3]) sl@0: { sl@0: count = 0; sl@0: err = TheDatabase.Commit(); sl@0: TEST2(err, KErrNone); sl@0: if(compaction) sl@0: { sl@0: err = TheDatabase.Compact(); sl@0: TEST2(err, KErrNone); sl@0: } sl@0: } sl@0: } sl@0: PrintFcDiffAsUs(_L("###RDbDatabase::Execute(), Time=%d us\r\n"), CalcTickDiff(fc, User::FastCounter())); sl@0: PrintFileSize(); sl@0: DestroyDatabase(); sl@0: } sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID PDS-DBMS-UT-4010 sl@0: @SYMTestCaseDesc Test for DEF141419 - DBMS, new performance tests - RDbUpdate, RDbStoreDatabase. sl@0: Tests the performance of RDbColWriteStream::OpenLC() and RDbColWriteStream::OpenL(). sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for DEF141419 - DBMS, new performance tests - RDbUpdate, RDbStoreDatabase sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMDEF DEF141419 sl@0: */ sl@0: void DbColWriteStreamTestsL() sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:PDS-DBMS-UT-4010 RDbColWriteStream performance test")); sl@0: sl@0: TInt err = TheDatabase.Replace(TheFs, TheDatabaseFileName); sl@0: TEST2(err, KErrNone); sl@0: err = TheDatabase.Execute(KCreateTestTableSql2); sl@0: TEST(err >= 0); sl@0: sl@0: RDbView view; sl@0: err = view.Prepare(TheDatabase, _L("select * from A"), view.EInsertOnly); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet = view; sl@0: sl@0: CDbColSet* colSet = TheRowSet.ColSetL(); sl@0: const TDbColNo KIdx1 = colSet->ColNo(_L("I1")); sl@0: const TDbColNo KIdx2 = colSet->ColNo(_L("I2")); sl@0: const TDbColNo KIdx3 = colSet->ColNo(_L("I3")); sl@0: delete colSet; sl@0: sl@0: TheTextRndData.SetLength(KColSize2); sl@0: TheTextRndData.Fill(KBufChar); sl@0: TheBinRndData.SetLength(KColSize2); sl@0: TheBinRndData.Fill(KBufChar); sl@0: sl@0: err = TheDatabase.Begin(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: TUint32 openLcFc = 0; sl@0: TUint32 openLFc = 0; sl@0: TUint32 fc = User::FastCounter(); sl@0: sl@0: for(TInt i=0;iColNo(_L("I1")); sl@0: const TDbColNo KIdx2 = colSet->ColNo(_L("I2")); sl@0: const TDbColNo KIdx3 = colSet->ColNo(_L("I3")); sl@0: delete colSet; sl@0: sl@0: TBuf8 binData; sl@0: TBuf16 textData; sl@0: sl@0: TInt recCnt = 0; sl@0: TUint32 openLcFc = 0; sl@0: TUint32 openLFc = 0; sl@0: TUint32 fc = User::FastCounter(); sl@0: sl@0: if(TheRowSet.FirstL()) sl@0: { sl@0: do sl@0: { sl@0: TheRowSet.GetL(); sl@0: ++recCnt; sl@0: sl@0: TInt i1 = TheRowSet.ColInt(KIdx1); sl@0: TEST2(recCnt, i1); sl@0: sl@0: RDbColReadStream strm1; sl@0: TUint32 tmp = User::FastCounter(); sl@0: strm1.OpenLC(TheRowSet, KIdx2); sl@0: openLcFc += CalcTickDiff(tmp, User::FastCounter()); sl@0: strm1.ReadL(textData, KColSize2); sl@0: CleanupStack::PopAndDestroy(&strm1); sl@0: TEST(textData == TheTextRndData); sl@0: sl@0: RDbColReadStream strm2; sl@0: CleanupClosePushL(strm2); sl@0: tmp = User::FastCounter(); sl@0: strm2.OpenL(TheRowSet, KIdx3); sl@0: openLFc += CalcTickDiff(tmp, User::FastCounter()); sl@0: strm2.ReadL(binData, KColSize2); sl@0: CleanupStack::PopAndDestroy(&strm2); sl@0: TEST(binData == TheBinRndData); sl@0: } while(TheRowSet.NextL()); sl@0: } sl@0: TEST2(recCnt, KTestRecordCount); sl@0: sl@0: PrintFcDiffAsUs2(_L("###RDbColReadStream, read %3d records, Time=%d us\r\n"), sl@0: recCnt, CalcTickDiff(fc, User::FastCounter())); sl@0: PrintFcDiffAsUs (_L("###OpenLC() , Time=%d us\r\n"), openLcFc); sl@0: PrintFcDiffAsUs (_L("###OpenL() , Time=%d us\r\n"), openLFc); sl@0: sl@0: TheRowSet.Close(); sl@0: sl@0: TheDatabase.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID PDS-DBMS-UT-4012 sl@0: @SYMTestCaseDesc Test for DEF141419 - DBMS, new performance tests - RDbUpdate, RDbStoreDatabase. sl@0: RDbUpdate performance tests. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for DEF141419 - DBMS, new performance tests - RDbUpdate, RDbStoreDatabase sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMDEF DEF141419 sl@0: */ sl@0: void DbUpdateTestL() sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:PDS-DBMS-UT-4012 RDbUpdate performance test")); sl@0: sl@0: TInt err = TheDbs.Connect(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = TheDatabase.Open(TheDbs, TheDatabaseFileName); sl@0: TEST2(err, KErrNone); sl@0: sl@0: TUint32 execFc = 0; sl@0: TUint32 nextFc = 0; sl@0: TUint32 rowCntFc = 0; sl@0: sl@0: //Synchronous update sl@0: TInt recCnt = 0; sl@0: RDbUpdate upd1; sl@0: TUint32 fc = User::FastCounter(); sl@0: err = upd1.Execute(TheDatabase, _L("UPDATE A SET I1=1000, I2='8888888888888888'")); sl@0: execFc = CalcTickDiff(fc, User::FastCounter()); sl@0: TEST2(err, KErrNone); sl@0: TUint32 tmp = User::FastCounter(); sl@0: while((err = upd1.Next()) > 0) sl@0: { sl@0: } sl@0: nextFc = CalcTickDiff(tmp, User::FastCounter()); sl@0: tmp = User::FastCounter(); sl@0: recCnt = upd1.RowCount(); sl@0: rowCntFc = CalcTickDiff(tmp, User::FastCounter()); sl@0: upd1.Close(); sl@0: fc = CalcTickDiff(fc, User::FastCounter()); sl@0: TEST2(err, 0); sl@0: TEST2(recCnt, KTestRecordCount); sl@0: sl@0: TheDatabase.Close(); sl@0: sl@0: PrintFcDiffAsUs2(_L("###Sync RDbUpdate, %3d records, Time=%d us\r\n"), recCnt, fc); sl@0: PrintFcDiffAsUs (_L("###Execute() , Time=%d us\r\n"), execFc); sl@0: PrintFcDiffAsUs (_L("###Next() , Time=%d us\r\n"), nextFc); sl@0: PrintFcDiffAsUs (_L("###RowCount() , Time=%d us\r\n"), rowCntFc); sl@0: sl@0: //Asynchronous update sl@0: err = TheDatabase.Open(TheDbs, TheDatabaseFileName); sl@0: TEST2(err, KErrNone); sl@0: sl@0: execFc = 0; sl@0: nextFc = 0; sl@0: rowCntFc = 0; sl@0: recCnt = 0; sl@0: sl@0: RDbUpdate upd2; sl@0: fc = User::FastCounter(); sl@0: err = upd2.Execute(TheDatabase, _L("UPDATE A SET I1=5678, I2='9w27u22272252542r2242242424221'")); sl@0: execFc = CalcTickDiff(fc, User::FastCounter()); sl@0: TEST2(err, KErrNone); sl@0: TRequestStatus stat; sl@0: tmp = User::FastCounter(); sl@0: do sl@0: { sl@0: upd2.Next(stat); sl@0: User::WaitForRequest(stat); sl@0: } while(stat.Int() > 0); sl@0: nextFc = CalcTickDiff(tmp, User::FastCounter()); sl@0: tmp = User::FastCounter(); sl@0: recCnt = upd2.RowCount(); sl@0: rowCntFc = CalcTickDiff(tmp, User::FastCounter()); sl@0: upd2.Close(); sl@0: fc = CalcTickDiff(fc, User::FastCounter()); sl@0: TEST2(stat.Int(), 0); sl@0: TEST2(recCnt, KTestRecordCount); sl@0: sl@0: TheDatabase.Close(); sl@0: sl@0: PrintFcDiffAsUs2(_L("###Async RDbUpdate, %3d records, Time=%d us\r\n"), recCnt, fc); sl@0: PrintFcDiffAsUs (_L("###Execute() , Time=%d us\r\n"), execFc); sl@0: PrintFcDiffAsUs (_L("###Next() , Time=%d us\r\n"), nextFc); sl@0: PrintFcDiffAsUs (_L("###RowCount() , Time=%d us\r\n"), rowCntFc); sl@0: sl@0: TheDbs.Close(); sl@0: err = TheFs.Delete(TheDatabaseFileName); sl@0: TEST2(err, KErrNone); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID PDS-DBMS-UT-4013 sl@0: @SYMTestCaseDesc Test for DEF141419 - DBMS, new performance tests - RDbUpdate, RDbStoreDatabase. sl@0: RDbStoreDatabase performance tests. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for DEF141419 - DBMS, new performance tests - RDbUpdate, RDbStoreDatabase. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMDEF DEF141419 sl@0: */ sl@0: void DbStoreDatabaseTestL() sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:PDS-DBMS-UT-4013 RDbStoreDatabase performance test")); sl@0: sl@0: CFileStore* fstore = CPermanentFileStore::ReplaceLC(TheFs, TheDatabaseFileName, EFileRead | EFileWrite); sl@0: fstore->SetTypeL(fstore->Layout()); sl@0: sl@0: //Create the database, insert records, compress the store. sl@0: sl@0: RDbStoreDatabase db1; sl@0: CleanupClosePushL(db1); sl@0: TUint32 fc = User::FastCounter(); sl@0: TStreamId strmId = db1.CreateL(fstore); sl@0: TUint32 createFc = CalcTickDiff(fc, User::FastCounter()); sl@0: sl@0: TInt err = db1.Execute(KCreateTestTableSql2); sl@0: TEST(err >= 0); sl@0: err = db1.Begin(); sl@0: TEST2(err, 0); sl@0: for(TInt i=0;iFile().Size(fsize1); sl@0: TEST2(err, KErrNone); sl@0: sl@0: fc = User::FastCounter(); sl@0: RDbStoreDatabase::CompressL(*fstore, strmId); sl@0: TUint32 compressFc = CalcTickDiff(fc, User::FastCounter()); sl@0: sl@0: TInt fsize2 = 0; sl@0: err = fstore->File().Size(fsize2); sl@0: TEST2(err, KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(fstore); sl@0: sl@0: PrintFcDiffAsUs2(_L("###RDbStoreDatabase, write %3d records, Time=%d us\r\n"), KTestRecordCount, writeFc); sl@0: PrintFcDiffAsUs (_L("###CreateL() , Time=%d us\r\n"), createFc); sl@0: PrintFcDiffAsUs (_L("###CompressL() , Time=%d us\r\n"), compressFc); sl@0: sl@0: //Decompress the store, open the database, read the records sl@0: sl@0: fstore = CPermanentFileStore::OpenLC(TheFs, TheDatabaseFileName, EFileRead | EFileWrite); sl@0: fstore->SetTypeL(fstore->Layout()); sl@0: sl@0: fc = User::FastCounter(); sl@0: RDbStoreDatabase::DecompressL(*fstore, strmId); sl@0: TUint32 decompressFc = CalcTickDiff(fc, User::FastCounter()); sl@0: sl@0: TInt fsize3 = 0; sl@0: err = fstore->File().Size(fsize3); sl@0: TEST2(err, KErrNone); sl@0: sl@0: RDbStoreDatabase db2; sl@0: CleanupClosePushL(db2); sl@0: fc = User::FastCounter(); sl@0: db2.OpenL(fstore, strmId); sl@0: TUint32 openFc = CalcTickDiff(fc, User::FastCounter()); sl@0: sl@0: RDbView view; sl@0: err = view.Prepare(db2, _L("SELECT * FROM A")); sl@0: TEST2(err, KErrNone); sl@0: err = view.EvaluateAll(); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet = view; sl@0: sl@0: CDbColSet* colSet = TheRowSet.ColSetL(); sl@0: const TDbColNo KIdx1 = colSet->ColNo(_L("I1")); sl@0: const TDbColNo KIdx2 = colSet->ColNo(_L("I2")); sl@0: const TDbColNo KIdx3 = colSet->ColNo(_L("I3")); sl@0: delete colSet; sl@0: sl@0: TInt recCnt = 0; sl@0: if(TheRowSet.FirstL()) sl@0: { sl@0: do sl@0: { sl@0: TheRowSet.GetL(); sl@0: ++recCnt; sl@0: sl@0: RDbColReadStream strm1; sl@0: strm1.OpenLC(TheRowSet, KIdx2); sl@0: TBuf buf; sl@0: _LIT(KText, "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZAAAAAAAAAAAAAAAAAAAAAAAAAAAA");//the same as the used in the INSERT statement above sl@0: strm1.ReadL(buf, KText().Length()); sl@0: CleanupStack::PopAndDestroy(&strm1); sl@0: TEST(KText() == buf); sl@0: } while(TheRowSet.NextL()); sl@0: } sl@0: TEST2(recCnt, KTestRecordCount); sl@0: sl@0: TheRowSet.Close(); sl@0: TUint32 readFc = CalcTickDiff(fc, User::FastCounter()); sl@0: sl@0: CleanupStack::PopAndDestroy(&db2); sl@0: CleanupStack::PopAndDestroy(fstore); sl@0: sl@0: PrintFcDiffAsUs2(_L("###RDbStoreDatabase, read %3d records , Time=%d us\r\n"), recCnt, readFc); sl@0: PrintFcDiffAsUs (_L("###OpenL() , Time=%d us\r\n"), openFc); sl@0: PrintFcDiffAsUs (_L("###DecompressL() , Time=%d us\r\n"), decompressFc); sl@0: TheTest.Printf(_L("###File size. After write: %d. After Compress(): %d. After Decompress(): %d\r\n"), fsize1, fsize2, fsize3); sl@0: sl@0: err = TheFs.Delete(TheDatabaseFileName); sl@0: TEST2(err, KErrNone); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID PDS-DBMS-UT-4014 sl@0: @SYMTestCaseDesc Test for DEF141419 - DBMS, new performance tests - RDbUpdate, RDbStoreDatabase. sl@0: RDbDatabase performance tests. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for DEF141419 - DBMS, new performance tests - RDbUpdate, RDbStoreDatabase. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMDEF DEF141419 sl@0: */ sl@0: void DbDatabaseTestL() sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:PDS-DBMS-UT-4014 RDbDatabase performance test")); sl@0: sl@0: TInt err = TheDatabase.Replace(TheFs, TheDatabaseFileName); sl@0: TEST2(err, KErrNone); sl@0: sl@0: //CDbColSet sl@0: _LIT(KColName1, "Col1"); sl@0: _LIT(KColName2, "Col2"); sl@0: _LIT(KColName3, "Col3"); sl@0: TUint32 fc = User::FastCounter(); sl@0: CDbColSet* colset = CDbColSet::NewLC(); sl@0: TDbCol col1(KColName1, EDbColInt32); sl@0: colset->AddL(col1); sl@0: TDbCol col2(KColName2, EDbColText16, 100); sl@0: colset->AddL(col2); sl@0: TDbCol col3(KColName3, EDbColBinary, 100); sl@0: colset->AddL(col3); sl@0: TUint32 colSetFc = CalcTickDiff(fc, User::FastCounter()); sl@0: PrintFcDiffAsUs(_L("###CDbColSet::NewLC() & CDbColSet::AddL(), Time=%d us\r\n"), colSetFc); sl@0: sl@0: //RDbDatabase::CreateTable() sl@0: _LIT(KTblName, "ATbl"); sl@0: fc = User::FastCounter(); sl@0: err = TheDatabase.CreateTable(KTblName, *colset); sl@0: TUint32 createTblFc = CalcTickDiff(fc, User::FastCounter()); sl@0: TEST2(err, KErrNone); sl@0: PrintFcDiffAsUs(_L("###RDbDatabase::CreateTable(), Time=%d us\r\n"), createTblFc); sl@0: sl@0: //RDbDatabase::AlterTable() sl@0: _LIT(KColName4, "Col4"); sl@0: TDbCol col4(KColName4, EDbColReal64); sl@0: colset->AddL(col4); sl@0: fc = User::FastCounter(); sl@0: err = TheDatabase.AlterTable(KTblName, *colset); sl@0: TUint32 alterTblFc = CalcTickDiff(fc, User::FastCounter()); sl@0: TEST2(err, KErrNone); sl@0: PrintFcDiffAsUs(_L("###RDbDatabase::AlterTable(), Time=%d us\r\n"), alterTblFc); sl@0: sl@0: //CDbKey sl@0: fc = User::FastCounter(); sl@0: CDbKey* dbKey = CDbKey::NewLC(); sl@0: TDbKeyCol keyCol1(KColName1, TDbKeyCol::EAsc); sl@0: dbKey->AddL(keyCol1); sl@0: TDbKeyCol keyCol2(KColName4, TDbKeyCol::EDesc); sl@0: dbKey->AddL(keyCol2); sl@0: TUint32 dbKeyFc = CalcTickDiff(fc, User::FastCounter()); sl@0: PrintFcDiffAsUs(_L("###CDbKey::NewLC() & CDbKey::AddL(), Time=%d us\r\n"), dbKeyFc); sl@0: sl@0: //RDbDatabase::CreateIndex() sl@0: _LIT(KKeyName, "AKey"); sl@0: fc = User::FastCounter(); sl@0: err = TheDatabase.CreateIndex(KKeyName, KTblName, *dbKey); sl@0: TUint32 createIndexFc = CalcTickDiff(fc, User::FastCounter()); sl@0: TEST2(err, KErrNone); sl@0: PrintFcDiffAsUs(_L("###RDbDatabase::CreateIndex(), Time=%d us\r\n"), createIndexFc); sl@0: sl@0: CleanupStack::PopAndDestroy(dbKey); sl@0: CleanupStack::PopAndDestroy(colset); sl@0: sl@0: //RDbDatabase::TableNamesL() sl@0: fc = User::FastCounter(); sl@0: CDbTableNames* tblNames = TheDatabase.TableNamesL(); sl@0: TUint32 tblNamesFc = CalcTickDiff(fc, User::FastCounter()); sl@0: delete tblNames; sl@0: PrintFcDiffAsUs(_L("###RDbDatabase::TableNamesL(), Time=%d us\r\n"), tblNamesFc); sl@0: sl@0: //RDbDatabase::IndexNamesL() sl@0: fc = User::FastCounter(); sl@0: CDbIndexNames* idxNames = TheDatabase.IndexNamesL(KTblName); sl@0: TUint32 idxNamesFc = CalcTickDiff(fc, User::FastCounter()); sl@0: delete idxNames; sl@0: PrintFcDiffAsUs(_L("###RDbDatabase::IndexNamesL(), Time=%d us\r\n"), idxNamesFc); sl@0: sl@0: //RDbDatabase::ColSetL() sl@0: fc = User::FastCounter(); sl@0: colset = TheDatabase.ColSetL(KTblName); sl@0: colSetFc = CalcTickDiff(fc, User::FastCounter()); sl@0: delete colset; sl@0: PrintFcDiffAsUs(_L("###RDbDatabase::ColSetL(), Time=%d us\r\n"), colSetFc); sl@0: sl@0: //RDbDatabase::KeyL() sl@0: fc = User::FastCounter(); sl@0: dbKey = TheDatabase.KeyL(KKeyName, KTblName); sl@0: dbKeyFc = CalcTickDiff(fc, User::FastCounter()); sl@0: delete dbKey; sl@0: PrintFcDiffAsUs(_L("###RDbDatabase::KeyL(), Time=%d us\r\n"), dbKeyFc); sl@0: sl@0: //RDbDatabase::DropIndex() sl@0: fc = User::FastCounter(); sl@0: err = TheDatabase.DropIndex(KKeyName, KTblName); sl@0: TUint32 dropIdxFc = CalcTickDiff(fc, User::FastCounter()); sl@0: TEST2(err, KErrNone); sl@0: PrintFcDiffAsUs(_L("###RDbDatabase::DropIndex(), Time=%d us\r\n"), dropIdxFc); sl@0: sl@0: //RDbDatabase::DropTable() sl@0: fc = User::FastCounter(); sl@0: err = TheDatabase.DropTable(KTblName); sl@0: TUint32 dropTblFc = CalcTickDiff(fc, User::FastCounter()); sl@0: TEST2(err, KErrNone); sl@0: PrintFcDiffAsUs(_L("###RDbDatabase::DropTable(), Time=%d us\r\n"), dropTblFc); sl@0: sl@0: TheDatabase.Close(); sl@0: } sl@0: sl@0: void PrintDiskUsage(const TDesC& aPath, TInt aOffset = 0) sl@0: { sl@0: _LIT(KSpace, " "); sl@0: TheTest.Printf(_L("%*.*S%S\r\n"), aOffset, aOffset, &KSpace, &aPath); sl@0: TFindFile* findFile = new TFindFile(TheFs);//TFindFile has TParse data member. sl@0: //Since this function is called recoursively, on some platforms sl@0: //the test might crash - "stack overflow" problem. sl@0: TEST(findFile != NULL); sl@0: CDir* fileNameCol = NULL; sl@0: TBuf<8> fileNameMask; sl@0: fileNameMask.Copy(_L("*.*")); sl@0: TInt err = findFile->FindWildByDir(fileNameMask, aPath, fileNameCol); sl@0: if(err == KErrNone) sl@0: { sl@0: do sl@0: { sl@0: const TDesC& file = findFile->File();//"file" variable contains the drive and the path. the file name in "file" is invalid in this case. sl@0: (void)TheParse.Set(file, NULL, NULL); sl@0: TPtrC driveName = TheParse.Drive(); sl@0: if(aPath.FindF(driveName) >= 0) sl@0: { sl@0: TInt cnt = fileNameCol->Count(); sl@0: for(TInt i=0;iCopy(aPath); sl@0: path->Append(entry.iName); sl@0: path->Append(_L("\\")); sl@0: PrintDiskUsage(*path, aOffset + 4); sl@0: delete path; sl@0: } sl@0: } sl@0: } // if(aPath.FindF(driveName) >= 0) sl@0: sl@0: delete fileNameCol; sl@0: fileNameCol = NULL; sl@0: } while((err = findFile->FindWild(fileNameCol)) == KErrNone);//Get the next set of files sl@0: } sl@0: else sl@0: { sl@0: TheTest.Printf(_L(" FindWildByDir() failed with err=%d\r\n"), err); sl@0: } sl@0: delete findFile; sl@0: } sl@0: sl@0: void DoTestL() sl@0: { sl@0: GetFastCounterFrequency(); sl@0: sl@0: FileBlockSizeTestsL(); sl@0: sl@0: RecordLenTestL(); sl@0: sl@0: InsertTestsL(); sl@0: sl@0: UpdateTestsL(); sl@0: sl@0: DbInsertTestsL(); sl@0: sl@0: DbUpdateTestsL(); sl@0: sl@0: DbColWriteStreamTestsL(); sl@0: sl@0: DbColReadStreamTestsL(); sl@0: sl@0: DbUpdateTestL(); sl@0: sl@0: DbStoreDatabaseTestL(); sl@0: sl@0: DbDatabaseTestL(); sl@0: } sl@0: sl@0: //Usage: "t_dbperf2 [:]" sl@0: TInt E32Main() sl@0: { sl@0: TheTest.Title(); sl@0: sl@0: TheTrapCleanup = CTrapCleanup::New(); sl@0: TEST(TheTrapCleanup != NULL); sl@0: sl@0: //Construct test database file name sl@0: _LIT(KTestDatabase, "c:\\dbms-tst\\t_dbperf2.db"); sl@0: TFileName fname; sl@0: User::CommandLine(fname); sl@0: TParse parse; sl@0: parse.Set(fname, &KTestDatabase, 0); sl@0: const TDesC& dbFilePath = parse.FullName(); sl@0: TheDatabaseFileName.Copy(dbFilePath); sl@0: TheTest.Printf(_L("Test database: %S\r\n"), &TheDatabaseFileName); sl@0: //Construct test file name sl@0: _LIT(KTestFile, "c:\\dbms-tst\\t_dbperf2.dat"); sl@0: parse.Set(fname, &KTestFile, 0); sl@0: const TDesC& testFilePath = parse.FullName(); sl@0: TheTestFileName.Copy(testFilePath); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TInt err = TheFs.Connect(); sl@0: TEST2(err, KErrNone); sl@0: err = TheFs.MkDir(TheDatabaseFileName); sl@0: TheTest.Printf(_L("MkDir(): err=%d\r\n"), err); sl@0: TEST(err == KErrNone || err == KErrAlreadyExists); sl@0: sl@0: DeleteFile(TheDatabaseFileName); sl@0: TRAP(err, DoTestL()); sl@0: DeleteFile(TheDatabaseFileName); sl@0: DeleteFile(TheTestFileName); sl@0: TEST2(err, KErrNone); sl@0: sl@0: TheTest.Printf(_L("====================== Disk usage ==================\r\n")); sl@0: PrintDiskUsage(_L("c:\\")); sl@0: TheTest.Printf(_L("====================================================\r\n")); sl@0: sl@0: CloseAll(); sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: TheTest.End(); sl@0: TheTest.Close(); sl@0: sl@0: delete TheTrapCleanup; sl@0: return KErrNone; sl@0: }