Update contrib.
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 ///////////////////////////////////////////////////////////////////////////////////////
24 RTest TheTest(_L("t_dbperf1"));
28 TFileName TheNonSecureDbName;
29 TFileName TheNonSecureDbName2;
30 _LIT(KFillDbScript, "z:\\test\\t_dbperf1.sql");
31 _LIT(KUpdateSql, "UPDATE IDENTITYTABLE SET CM_FIRSTNAME='%S%d',CM_LASTNAME='%S%d',CM_COMPANYNAME='%S%d' WHERE PARENT_CMID=%d");
32 _LIT(KSelectSql, "SELECT CM_FIRSTNAME, CM_LASTNAME, CM_COMPANYNAME FROM IDENTITYTABLE WHERE PARENT_CMID > 50");
33 _LIT(KDeleteSql, "DELETE FROM IDENTITYTABLE WHERE PARENT_CMID > 50");
34 _LIT(KFirstName, "FirstName-");
35 _LIT(KLastName, "LastName-");
36 _LIT(KCompanyName, "CompanyName-");
38 const TInt KTestTecordCount = 1000;
50 ECompactAfterEvery10Rec,
51 ECompactAfterEveryUpd,
55 ///////////////////////////////////////////////////////////////////////////////////////
60 TheFs.Delete(TheNonSecureDbName2);
61 TheFs.Delete(TheNonSecureDbName);
65 ///////////////////////////////////////////////////////////////////////////////////////
66 ///////////////////////////////////////////////////////////////////////////////////////
67 //Test macros and functions
68 void Check1(TInt aValue, TInt aLine)
73 TheTest.Printf(_L("*** Line %d\r\n"), aLine);
74 TheTest(EFalse, aLine);
77 void Check2(TInt aValue, TInt aExpected, TInt aLine)
79 if(aValue != aExpected)
82 TheTest.Printf(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
83 TheTest(EFalse, aLine);
86 #define TEST(arg) ::Check1((arg), __LINE__)
87 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
89 ///////////////////////////////////////////////////////////////////////////////////////
93 TInt err = TheFs.Connect();
96 err = TheFs.MkDir(TheNonSecureDbName);
97 TEST(err == KErrNone || err == KErrAlreadyExists);
99 err = TheDbs.Connect();
100 TEST2(err, KErrNone);
103 //Reads a SQL file and returns the file content as HBUFC string.
104 //The caller is responsible for destroying the returned HBufC object.
105 HBufC* ReadSqlScript(const TDesC& aSqlFileName)
108 TEST2(file.Open(TheFs, aSqlFileName, EFileRead), KErrNone);
111 TEST2(file.Size(size), KErrNone);
113 HBufC8* sql = HBufC8::New(size);
116 TPtr8 ptr = sql->Des();
117 TEST2(file.Read(ptr, size), KErrNone);
121 HBufC* sql2 = HBufC::New(size);
123 sql2->Des().Copy(sql->Des());
129 //Searches for the next ';' appearance in aSqlScript string and returns a TPtrC object holding
130 //the SQL statement, terminated with that ';'.
131 TPtrC GetNextStmt(TPtrC& aSqlScript)
133 _LIT(KTerminator, ";\xD");
135 TInt pos = aSqlScript.FindF(KTerminator());
138 res.Set(aSqlScript.Left(pos));
140 aSqlScript.Set(aSqlScript.Mid(pos));
145 //Prints aTime parameter (converted to ms)
146 void PrintStats(TUint32 aStartTicks, TUint32 aEndTicks)
148 static TInt freq = 0;
151 TEST2(HAL::Get(HAL::EFastCounterFrequency, freq), KErrNone);
153 TInt64 diffTicks = (TInt64)aEndTicks - (TInt64)aStartTicks;
156 diffTicks = KMaxTUint32 + diffTicks + 1;
158 const TInt KMicroSecIn1Sec = 1000000;
159 TInt32 us = (diffTicks * KMicroSecIn1Sec) / freq;
160 TheTest.Printf(_L("####Execution time: %d ms\r\n"), us / 1000);
163 void PrintFileSize(const TDesC& aFileName)
166 TInt err = file.Open(TheFs, aFileName, EFileRead);
167 TEST2(err, KErrNone);
169 err = file.Size(size);
170 TEST2(err, KErrNone);
171 TheTest.Printf(_L("####FileSize: %d\r\n"), size);
175 void PrintString(const TDesC& aStr)
177 TheTest.Printf(_L("Str begin~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n"));
179 while(ptr.Length() > 0)
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));
187 TheTest.Printf(_L("Str end~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n"));
190 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
191 /////// DBMS SERVER performance tests
192 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
194 //Creates aDb database schema.
195 void CreateDbSchemaL(RDbDatabase& aDb)
198 CDbColSet* colSet = CDbColSet::NewLC();
199 colSet->AddL(TDbCol(_L("cm_id"), EDbColInt32, TDbCol::ENotNull));
200 colSet->AddL(TDbCol(_L("cm_type"), EDbColInt32, TDbCol::ENotNull));
201 colSet->AddL(TDbCol(_L("cm_preftemplaterefid"), EDbColInt32));
202 colSet->AddL(TDbCol(_L("cm_uidstring"), EDbColText, 244));
203 colSet->AddL(TDbCol(_L("cm_last_modified"), EDbColDateTime));
204 colSet->AddL(TDbCol(_L("cm_contactcreationdate"), EDbColDateTime));
205 colSet->AddL(TDbCol(_L("cm_attributes"), EDbColInt32, TDbCol::ENotNull));
206 colSet->AddL(TDbCol(_L("cm_replicationcount"), EDbColInt32, TDbCol::ENotNull));
207 colSet->AddL(TDbCol(_L("cm_header"), EDbColLongText));
208 colSet->AddL(TDbCol(_L("cm_textblob"), EDbColLongText));
209 colSet->AddL(TDbCol(_L("cm_searchabletext"), EDbColLongText));
210 TInt err = aDb.CreateTable(_L("contacts"), *colSet);
211 TEST2(err, KErrNone);
212 CleanupStack::PopAndDestroy(); colSet = NULL;
213 //"identitytable" table
214 colSet = CDbColSet::NewLC();
215 colSet->AddL(TDbCol(_L("parent_cmid"), EDbColInt32, TDbCol::ENotNull));
216 colSet->AddL(TDbCol(_L("cm_firstname"), EDbColText, 255));
217 colSet->AddL(TDbCol(_L("cm_lastname"), EDbColText, 255));
218 colSet->AddL(TDbCol(_L("cm_companyname"), EDbColText, 255));
219 colSet->AddL(TDbCol(_L("cm_type"), EDbColInt32));
220 colSet->AddL(TDbCol(_L("cm_attributes"), EDbColInt32));
221 colSet->AddL(TDbCol(_L("cm_hintfield"), EDbColUint8));
222 colSet->AddL(TDbCol(_L("cm_exthintfield"), EDbColUint16));
223 colSet->AddL(TDbCol(_L("cm_firstnmprn"), EDbColText, 255));
224 colSet->AddL(TDbCol(_L("cm_lastnmprn"), EDbColText, 255));
225 colSet->AddL(TDbCol(_L("cm_companynmprn"), EDbColText, 255));
226 err = aDb.CreateTable(_L("identitytable"), *colSet);
227 TEST2(err, KErrNone);
228 CleanupStack::PopAndDestroy(); colSet = NULL;
230 colSet = CDbColSet::NewLC();
231 colSet->AddL(TDbCol(_L("emailparent_cmid"), EDbColInt32, TDbCol::ENotNull));
232 colSet->AddL(TDbCol(_L("email_fieldid"), EDbColInt32, TDbCol::ENotNull));
233 colSet->AddL(TDbCol(_L("emailaddress"), EDbColText, 255));
234 err = aDb.CreateTable(_L("emailtable"), *colSet);
235 TEST2(err, KErrNone);
236 CleanupStack::PopAndDestroy(); colSet = NULL;
238 colSet = CDbColSet::NewLC();
239 colSet->AddL(TDbCol(_L("cm_id"), EDbColInt32, TDbCol::ENotNull));
240 colSet->AddL(TDbCol(_L("cm_phonematching"), EDbColInt32, TDbCol::ENotNull));
241 colSet->AddL(TDbCol(_L("cm_extendedphonematching"), EDbColInt32, TDbCol::ENotNull));
242 err = aDb.CreateTable(_L("phone"), *colSet);
243 TEST2(err, KErrNone);
244 CleanupStack::PopAndDestroy(); colSet = NULL;
246 colSet = CDbColSet::NewLC();
247 colSet->AddL(TDbCol(_L("cm_id"), EDbColInt32, TDbCol::ENotNull));
248 colSet->AddL(TDbCol(_L("cm_members"), EDbColInt32, TDbCol::ENotNull));
249 err = aDb.CreateTable(_L("groups"), *colSet);
250 TEST2(err, KErrNone);
251 CleanupStack::PopAndDestroy(); colSet = NULL;
253 colSet = CDbColSet::NewLC();
254 colSet->AddL(TDbCol(_L("cm_id"), EDbColInt32, TDbCol::ENotNull));
255 colSet->AddL(TDbCol(_L("cm_groupmembers"), EDbColLongText));
256 err = aDb.CreateTable(_L("groups2"), *colSet);
257 TEST2(err, KErrNone);
258 CleanupStack::PopAndDestroy(); colSet = NULL;
260 colSet = CDbColSet::NewLC();
261 colSet->AddL(TDbCol(_L("cm_id"), EDbColInt32, TDbCol::ENotNull));
262 colSet->AddL(TDbCol(_L("cm_lastsyncdate"), EDbColDateTime));
263 err = aDb.CreateTable(_L("sync"), *colSet);
264 TEST2(err, KErrNone);
265 CleanupStack::PopAndDestroy(); colSet = NULL;
266 //"preferences" table
267 colSet = CDbColSet::NewLC();
268 colSet->AddL(TDbCol(_L("cm_preffileid"), EDbColInt16));
269 colSet->AddL(TDbCol(_L("cm_preftemplateid"), EDbColInt32, TDbCol::ENotNull));
270 colSet->AddL(TDbCol(_L("cm_prefowncardid"), EDbColInt32));
271 colSet->AddL(TDbCol(_L("cm_prefcardtemplateprefid"), EDbColInt32));
272 colSet->AddL(TDbCol(_L("cm_preffilever"), EDbColInt32, TDbCol::ENotNull));
273 colSet->AddL(TDbCol(_L("cm_prefcardtemplateid"), EDbColLongText));
274 colSet->AddL(TDbCol(_L("cm_prefgroupidlist"), EDbColLongText));
275 colSet->AddL(TDbCol(_L("cm_creationdate"), EDbColDateTime));
276 colSet->AddL(TDbCol(_L("cm_machineuid"), EDbColInt64));
277 colSet->AddL(TDbCol(_L("cm_prefsortorder"), EDbColLongText));
278 err = aDb.CreateTable(_L("preferences"), *colSet);
279 TEST2(err, KErrNone);
280 CleanupStack::PopAndDestroy(); colSet = NULL;
281 //////////////////////////////////////////////////////////////////////////////////////////////////////////
282 //////////////////////////////////////////////////////////////////////////////////////////////////////////
283 //"Contacts" table keys
284 CDbKey* key = CDbKey::NewLC();
285 key->AddL(_L("cm_id"));
287 err = aDb.CreateIndex(_L("contacts"), _L("contacts"), *key);
288 TEST2(err, KErrNone);
289 CleanupStack::PopAndDestroy(); key = NULL;
290 key = CDbKey::NewLC();
291 key->AddL(_L("cm_preftemplaterefid"));
292 err = aDb.CreateIndex(_L("cm_preftemplaterefid"), _L("contacts"), *key);
293 TEST2(err, KErrNone);
294 CleanupStack::PopAndDestroy(); key = NULL;
295 //"identitytable" table keys
296 key = CDbKey::NewLC();
297 key->AddL(_L("parent_cmid"));
299 err = aDb.CreateIndex(_L("identitytable"), _L("identitytable"), *key);
300 TEST2(err, KErrNone);
301 CleanupStack::PopAndDestroy(); key = NULL;
302 //"emailtable" table keys
303 key = CDbKey::NewLC();
304 key->AddL(_L("email_fieldid"));
305 key->AddL(_L("emailparent_cmid"));
307 err = aDb.CreateIndex(_L("emailtable"), _L("emailtable"), *key);
308 TEST2(err, KErrNone);
309 CleanupStack::PopAndDestroy(); key = NULL;
310 key = CDbKey::NewLC();
311 key->AddL(_L("emailparent_cmid"));
312 err = aDb.CreateIndex(_L("emailparent_cmid"), _L("emailtable"), *key);
313 TEST2(err, KErrNone);
314 CleanupStack::PopAndDestroy(); key = NULL;
316 key = CDbKey::NewLC();
317 key->AddL(_L("cm_phonematching"));
318 key->AddL(_L("cm_id"));
320 err = aDb.CreateIndex(_L("phone"), _L("phone"), *key);
321 TEST2(err, KErrNone);
322 CleanupStack::PopAndDestroy(); key = NULL;
323 key = CDbKey::NewLC();
324 key->AddL(_L("cm_id"));
325 err = aDb.CreateIndex(_L("cm_id"), _L("phone"), *key);
326 TEST2(err, KErrNone);
327 CleanupStack::PopAndDestroy(); key = NULL;
328 //"groups" table keys
329 key = CDbKey::NewLC();
330 key->AddL(_L("cm_members"));
331 key->AddL(_L("cm_id"));
333 err = aDb.CreateIndex(_L("groups"), _L("groups"), *key);
334 TEST2(err, KErrNone);
335 CleanupStack::PopAndDestroy(); key = NULL;
336 key = CDbKey::NewLC();
337 key->AddL(_L("cm_id"));
338 err = aDb.CreateIndex(_L("cm_id"), _L("groups"), *key);
339 TEST2(err, KErrNone);
340 CleanupStack::PopAndDestroy(); key = NULL;
341 key = CDbKey::NewLC();
342 key->AddL(_L("cm_members"));
343 err = aDb.CreateIndex(_L("cm_members"), _L("groups"), *key);
344 TEST2(err, KErrNone);
345 CleanupStack::PopAndDestroy(); key = NULL;
346 //"groups2" table keys
347 key = CDbKey::NewLC();
348 key->AddL(_L("cm_id"));
350 err = aDb.CreateIndex(_L("groups2"), _L("groups2"), *key);
351 TEST2(err, KErrNone);
352 CleanupStack::PopAndDestroy(); key = NULL;
354 key = CDbKey::NewLC();
355 key->AddL(_L("cm_id"));
357 err = aDb.CreateIndex(_L("sync"), _L("sync"), *key);
358 TEST2(err, KErrNone);
359 CleanupStack::PopAndDestroy(); key = NULL;
360 //"preferences" table keys
361 key = CDbKey::NewLC();
362 key->AddL(_L("cm_preftemplateid"));
363 err = aDb.CreateIndex(_L("cm_preftemplateid"), _L("preferences"), *key);
364 TEST2(err, KErrNone);
365 CleanupStack::PopAndDestroy(); key = NULL;
366 key = CDbKey::NewLC();
367 key->AddL(_L("cm_prefowncardid"));
368 err = aDb.CreateIndex(_L("cm_prefowncardid"), _L("preferences"), *key);
369 TEST2(err, KErrNone);
370 CleanupStack::PopAndDestroy(); key = NULL;
371 key = CDbKey::NewLC();
372 key->AddL(_L("cm_prefcardtemplateprefid"));
373 err = aDb.CreateIndex(_L("cm_prefcardtemplateprefid"), _L("preferences"), *key);
374 TEST2(err, KErrNone);
375 CleanupStack::PopAndDestroy(); key = NULL;
381 static void CreateL(const TDesC& aDbName)
384 TInt err = db.Replace(TheFs, aDbName);
385 TEST2(err, KErrNone);
389 static RDbDatabase Open(TTestType aTestType, const TDesC& aDbName)
392 TInt err = aTestType == EClientDbTest ? db.Open(TheFs, aDbName) : db.Open(TheDbs, aDbName);
393 TEST2(err, KErrNone);
398 //Executes SQL script
399 void ExecuteSqlScript(RDbDatabase& aDb, const TDesC& aScriptFileName, TCompactDbOption aCompactDbOpt)
401 if(aCompactDbOpt == ECompactAfterCommit)
403 TheTest.Printf(_L("===Execute DB script: Compact after COMMIT\r\n"));
405 else if(aCompactDbOpt == ECompactAtEnd)
407 TheTest.Printf(_L("===Execute DB script: Compact at end\r\n"));
411 TheTest.Printf(_L("===Execute DB script: No compaction\r\n"));
413 HBufC* fullDbScript = ReadSqlScript(aScriptFileName);
414 TUint32 start = User::FastCounter();
415 TPtrC ptr(fullDbScript->Des());
417 TInt err = aDb.Begin();
418 TEST2(err, KErrNone);
419 TPtrC sql(GetNextStmt(ptr));
420 while(sql.Length() > 0)
423 TInt rc = aDb.Execute(sql);
424 if(rc == KErrNoMemory)
426 TheTest.Printf(_L("###ERROR 'Out of memory'! The test cannot be completed!\r\n"));
434 if((stmtCnt % 200) == 0) //~16 transactions (~3270 statements total)
437 TEST2(err, KErrNone);
438 if(aCompactDbOpt == ECompactAfterCommit)
441 TEST2(err, KErrNone);
444 TEST2(err, KErrNone);
446 sql.Set(GetNextStmt(ptr));
449 TEST2(err, KErrNone);
450 if(aCompactDbOpt == ECompactAfterCommit || aCompactDbOpt == ECompactAtEnd)
453 TEST2(err, KErrNone);
455 TUint32 end = User::FastCounter();
456 PrintStats(start, end);
458 TheTest.Printf(_L("###Processed records: %d\r\n"), stmtCnt);
461 ///////////////////////////////////////////////////////////////////////////////////////
463 //"INSERT" test function
464 void InsertTest(TTestType aTestType, const TDesC& aDbFileName, TCompactDbOption aCompactDbOpt)
466 TheTest.Printf(_L("\"Insert\" test\r\n"));
467 RDbDatabase db = TDbHelper::Open(aTestType, aDbFileName);
468 ExecuteSqlScript(db, KFillDbScript, aCompactDbOpt);
470 TInt err = tbl.Open(db, _L("CONTACTS"));
471 TEST2(err, KErrNone);
473 TRAP(err, recCnt = tbl.CountL());
474 TEST2(err, KErrNone);
480 //"UPDATE" test function
481 void UpdateTest(TTestType aTestType, const TDesC& aDbFileName, const TDesC& aUpdateSql, TCompactDbOption aCompactDbOpt)
483 if(aCompactDbOpt == ECompactAfterEvery10Rec)
485 TheTest.Printf(_L("===Update: Compact after every 10 records\r\n"));
487 else if(aCompactDbOpt == ECompactAfterEveryUpd)
489 TheTest.Printf(_L("===Update: Compact after every update\r\n"));
491 else if(aCompactDbOpt == ECompactAtEnd)
493 TheTest.Printf(_L("===Update: Compact at end\r\n"));
497 TheTest.Printf(_L("===Update: No compaction\r\n"));
499 TheTest.Printf(_L("\"Update\" test\r\n"));
500 RDbDatabase db = TDbHelper::Open(aTestType, aDbFileName);
502 TUint32 start = User::FastCounter();
503 for(TInt id=1,updateOpCnt=0;id<=KTestTecordCount;++id,++updateOpCnt)
506 sql.Format(aUpdateSql, &KFirstName, id, &KLastName, id, &KCompanyName, id, id);
507 TInt rc = db.Execute(sql);
513 if(aCompactDbOpt == ECompactAfterEveryUpd || (aCompactDbOpt == ECompactAfterEvery10Rec && (updateOpCnt % 10) == 0))
515 TInt err = db.Compact();
516 TEST2(err, KErrNone);
519 if(aCompactDbOpt == ECompactAfterEvery10Rec || aCompactDbOpt == ECompactAtEnd)
521 TInt err = db.Compact();
522 TEST2(err, KErrNone);
524 TUint32 end = User::FastCounter();
525 PrintStats(start, end);
529 //"SELECT" test function
530 void SelectTestL(TTestType aTestType, const TDesC& aDbFileName, const TDesC& aSelectSql)
532 TheTest.Printf(_L("\"Select\" test\r\n"));
533 RDbDatabase db = TDbHelper::Open(aTestType, aDbFileName);
534 TDbQuery query(aSelectSql);
536 TInt err = view.Prepare(db, query, RDbRowSet::EReadOnly);
537 TEST2(err, KErrNone);
539 TUint32 start = User::FastCounter();
540 err = view.EvaluateAll();
541 TEST2(err, KErrNone);
547 colVal.Set(view.ColDes(1));
549 TEST(colVal.Length() > 0);
550 colVal.Set(view.ColDes(2));
551 TEST(colVal.Length() > 0);
553 colVal.Set(view.ColDes(3));
554 TEST(colVal.Length() > 0);
559 TUint32 end = User::FastCounter();
560 PrintStats(start, end);
564 //"DELETE" test function
565 void DeleteTest(TTestType aTestType, const TDesC& aDbFileName, const TDesC& aDeleteSql, TCompactDbOption aCompactDbOpt)
567 if(aCompactDbOpt == ECompactAtEnd)
569 TheTest.Printf(_L("===Delete: Compact at end\r\n"));
573 TheTest.Printf(_L("===Delete: No compaction\r\n"));
575 TheTest.Printf(_L("\"Delete\" test\r\n"));
576 RDbDatabase db = TDbHelper::Open(aTestType, aDbFileName);
577 TUint32 start = User::FastCounter();
578 TInt rc = db.Execute(aDeleteSql);
580 if(aCompactDbOpt == ECompactAtEnd)
582 TInt err = db.Compact();
583 TEST2(err, KErrNone);
585 TUint32 end = User::FastCounter();
586 PrintStats(start, end);
591 @SYMTestCaseID PDS-DBMS-CT-4008
592 @SYMTestCaseDesc DBMS server performance tests.
593 Three test types used: "insert records", "update records" and "select records".
594 The tests are executed on non-secure databases.
595 Each test executed using UTF16 encoded SQl statements.
596 The test results are used for a comparison against the SQL server test results
597 (T_SqlPerformance test).
598 @SYMTestPriority High
599 @SYMTestActions DBMS server performance tests.
600 @SYMTestExpectedResults Test must not fail
606 TheTest.Start(_L(" @SYMTestCaseID:PDS-DBMS-CT-4008 DBMS performance tests"));
608 CFileMan* fm = CFileMan::NewL(TheFs);
609 CleanupStack::PushL(fm);
611 //==================================== CLIENT ==========================================================
612 TheTest.Printf(_L("DBMS, insert, UTF16 SQL strings, non-secure db, client, no db compaction\r\n"));
613 TDbHelper::CreateL(TheNonSecureDbName);
614 InsertTest(EClientDbTest, TheNonSecureDbName, ENoCompaction);
615 PrintFileSize(TheNonSecureDbName);
617 TheTest.Printf(_L("DBMS, insert, UTF16 SQL strings, non-secure db, client, db compaction at end\r\n"));
618 TDbHelper::CreateL(TheNonSecureDbName);
619 InsertTest(EClientDbTest, TheNonSecureDbName, ECompactAtEnd);
620 PrintFileSize(TheNonSecureDbName);
622 TheTest.Printf(_L("DBMS, insert, UTF16 SQL strings, non-secure db, client, db compaction after commit\r\n"));
623 TDbHelper::CreateL(TheNonSecureDbName);
624 InsertTest(EClientDbTest, TheNonSecureDbName, ECompactAfterCommit);
625 PrintFileSize(TheNonSecureDbName);
627 TInt err = fm->Copy(TheNonSecureDbName, TheNonSecureDbName2);
628 TEST2(err, KErrNone);
630 TheTest.Printf(_L("DBMS, update, UTF16 SQL strings, non-secure db, client, no db compaction\r\n"));
631 UpdateTest(EClientDbTest, TheNonSecureDbName, KUpdateSql(), ENoCompaction);
632 PrintFileSize(TheNonSecureDbName);
633 err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
634 TEST2(err, KErrNone);
636 TheTest.Printf(_L("DBMS, update, UTF16 SQL strings, non-secure db, client, db compaction at end\r\n"));
637 UpdateTest(EClientDbTest, TheNonSecureDbName, KUpdateSql(), ECompactAtEnd);
638 PrintFileSize(TheNonSecureDbName);
639 err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
640 TEST2(err, KErrNone);
642 TheTest.Printf(_L("DBMS, update, UTF16 SQL strings, non-secure db, client, db compaction after every 10 records\r\n"));
643 UpdateTest(EClientDbTest, TheNonSecureDbName, KUpdateSql(), ECompactAfterEvery10Rec);
644 PrintFileSize(TheNonSecureDbName);
645 //L err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
646 //L TEST2(err, KErrNone);
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);
652 TheTest.Printf(_L("DBMS, select, UTF16 SQL strings, non-secure db, client\r\n"));
653 SelectTestL(EClientDbTest, TheNonSecureDbName, KSelectSql());
655 TheTest.Printf(_L("DBMS, delete, UTF16 SQL strings, non-secure db, client\r\n"));
656 DeleteTest(EClientDbTest, TheNonSecureDbName, KDeleteSql(), ECompactAtEnd);
657 PrintFileSize(TheNonSecureDbName);
659 //==================================== SERVER ==========================================================
661 TheTest.Printf(_L("DBMS, insert, UTF16 SQL strings, non-secure db, server, no db compaction\r\n"));
662 TDbHelper::CreateL(TheNonSecureDbName);
663 InsertTest(EServerDbTest, TheNonSecureDbName, ENoCompaction);
664 PrintFileSize(TheNonSecureDbName);
666 TheTest.Printf(_L("DBMS, insert, UTF16 SQL strings, non-secure db, server, db compaction at end\r\n"));
667 TDbHelper::CreateL(TheNonSecureDbName);
668 InsertTest(EServerDbTest, TheNonSecureDbName, ECompactAtEnd);
669 PrintFileSize(TheNonSecureDbName);
671 TheTest.Printf(_L("DBMS, insert, UTF16 SQL strings, non-secure db, server, db compaction after commit\r\n"));
672 TDbHelper::CreateL(TheNonSecureDbName);
673 InsertTest(EServerDbTest, TheNonSecureDbName, ECompactAfterCommit);
674 PrintFileSize(TheNonSecureDbName);
676 err = fm->Copy(TheNonSecureDbName, TheNonSecureDbName2);
677 TEST2(err, KErrNone);
679 TheTest.Printf(_L("DBMS, update, UTF16 SQL strings, non-secure db, server, no db compaction\r\n"));
680 UpdateTest(EServerDbTest, TheNonSecureDbName, KUpdateSql(), ENoCompaction);
681 PrintFileSize(TheNonSecureDbName);
682 err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
683 TEST2(err, KErrNone);
685 TheTest.Printf(_L("DBMS, update, UTF16 SQL strings, non-secure db, server, db compaction at end\r\n"));
686 UpdateTest(EServerDbTest, TheNonSecureDbName, KUpdateSql(), ECompactAtEnd);
687 PrintFileSize(TheNonSecureDbName);
688 err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
689 TEST2(err, KErrNone);
691 TheTest.Printf(_L("DBMS, update, UTF16 SQL strings, non-secure db, server, db compaction after every 10 records\r\n"));
692 UpdateTest(EServerDbTest, TheNonSecureDbName, KUpdateSql(), ECompactAfterEvery10Rec);
693 PrintFileSize(TheNonSecureDbName);
694 //L err = fm->Copy(TheNonSecureDbName2, TheNonSecureDbName);
695 //L TEST2(err, KErrNone);
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);
701 TheTest.Printf(_L("DBMS, select, UTF16 SQL strings, non-secure db, server\r\n"));
702 SelectTestL(EServerDbTest, TheNonSecureDbName, KSelectSql());
704 TheTest.Printf(_L("DBMS, delete, UTF16 SQL strings, non-secure db, server\r\n"));
705 DeleteTest(EServerDbTest, TheNonSecureDbName, KDeleteSql(), ECompactAtEnd);
706 PrintFileSize(TheNonSecureDbName);
708 //======================================================================================================
709 CleanupStack::PopAndDestroy(fm);
712 //Usage: "t_dbperf1 [<drive letter>:]"
718 CTrapCleanup* tc = CTrapCleanup::New();
720 //Construct test database file names, using the passed as an optional argument drive letter
723 User::CommandLine(fname);
725 _LIT(KNonSecureDbName, "c:\\test\\t_dbperf1_1.db");
726 parse.Set(fname, &KNonSecureDbName, 0);
727 const TDesC& dbFilePath1 = parse.FullName();
728 TheNonSecureDbName.Copy(dbFilePath1);
730 _LIT(KNonSecureDbName2, "c:\\test\\t_dbperf1_2.db");
731 parse.Set(fname, &KNonSecureDbName2, 0);
732 const TDesC& dbFilePath2 = parse.FullName();
733 TheNonSecureDbName2.Copy(dbFilePath2);
738 TRAPD(err, DoTestsL());
740 TEST2(err, KErrNone);
749 User::Heap().Check();