Update contrib.
1 // Copyright (c) 2009-2010 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.
13 // Description: MDS harvesting performance test
20 #include "t_sqlcmdlineutil.h"
22 RTest TheTest(_L("t_sqlperformance3 test"));
25 _LIT(KDbName, "c:\\test\\t_sqlperformance3.db");
27 TFileName TheDbFileName;
28 TBuf<200> TheTestTitle;
29 TCmdLineParams TheCmdLineParams(TCmdLineParams::EDbUtf16, 4096, 10000);
30 TBuf8<200> TheSqlConfigString;
33 _LIT(KUtf16, "UTF16");
35 TInt TheFastCounterFreq = 0;
37 const TInt KItemCnt = 1000;
38 const TInt KItemBlockSize = 100;
40 TInt TheIterations[100];
41 TInt TheIterationsCount = -1;
43 void CalcIterationsCount()
45 TheIterationsCount = KItemCnt / KItemBlockSize;
46 TInt r = KItemCnt % KItemBlockSize;
55 for(TInt i=0;i<(TheIterationsCount-1);++i)
57 TheIterations[i] = KItemBlockSize;
59 TheIterations[TheIterationsCount - 1] = r;
62 ////////////////////////////////////////////////////////////////////////////////////////////////////
67 (void)RSqlDatabase::Delete(TheDbFileName);
70 ///////////////////////////////////////////////////////////////////////////////////////
71 ///////////////////////////////////////////////////////////////////////////////////////
72 //Test macros and functions
73 void Check1(TInt aValue, TInt aLine)
78 TheTest.Printf(_L("*** Line %d\r\n"), aLine);
79 TheTest(EFalse, aLine);
82 void Check2(TInt aValue, TInt aExpected, TInt aLine)
84 if(aValue != aExpected)
86 TSqlRetCodeClass cl = SqlRetCodeClass(aValue);
89 TPtrC errmsg = TheDb.LastErrorMessage();
90 TheTest.Printf(_L("*** SQLite err=\"%S\"\r\n"), &errmsg);
93 TheTest.Printf(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
94 TheTest(EFalse, aLine);
97 #define TEST(arg) ::Check1((arg), __LINE__)
98 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
100 ///////////////////////////////////////////////////////////////////////////////////////
105 TInt err = fs.Connect();
106 TEST2(err, KErrNone);
107 err = fs.MkDirAll(TheDbFileName);
108 TEST(err == KErrNone || err == KErrAlreadyExists);
112 TInt TimeDiffUs(TUint32 aStartTicks, TUint32 aEndTicks)
114 if(TheFastCounterFreq == 0)
116 TEST2(HAL::Get(HAL::EFastCounterFrequency, TheFastCounterFreq), KErrNone);
118 TInt64 diffTicks = (TInt64)aEndTicks - (TInt64)aStartTicks;
121 diffTicks = KMaxTUint32 + diffTicks + 1;
123 const TInt KMicroSecIn1Sec = 1000000;
124 TInt us = (diffTicks * KMicroSecIn1Sec) / TheFastCounterFreq;
128 void PrintTime(const TDesC& aFmt, TUint32 aStartTicks, TUint32 aEndTicks)
130 TInt us = TimeDiffUs(aStartTicks, aEndTicks);
131 TheTest.Printf(aFmt, us);
134 //=============================================================================
135 TInt TheCreateDbCreateConnTime = 0;
136 TInt TheCreateDbOpenConnTime = 0;
137 TInt TheLastItemIdTime = 0;
138 TInt TheTableExistsTime = 0;
139 TInt TheMdeTablesCreationTime = 0;
140 TInt TheLastInsertedRowIdTime = 0;
141 TInt TheCreateTables1Time = 0;
142 TInt TheCreateTables2Time = 0;
143 TInt TheCreateTables3Time = 0;
144 TInt TheTransactionTime = 0;
145 TInt TheDbCreateTime = 0;
146 TInt TheCreateTriggersTime = 0;
147 TInt TheInsertEventRelationTime = 0;
148 TInt TheDeleteObjPropertyTime = 0;
149 TInt TheInsertCol2PropTime = 0;
150 TInt TheHarvestTime = 0;
151 TInt TheHarvestSelectTime = 0;
152 TInt TheHarvestInsertObjImageTime = 0;
153 TInt TheHarvestSelect2Time = 0;
154 TInt TheHarvestInsertEventTime = 0;
155 TInt TheHarvestUpdateObjImageTime = 0;
156 TInt TheHarvestSelect3Time = 0;
157 TInt TheHarvestSelect4Time = 0;
158 TInt TheHarvestUpdateObjTime = 0;
159 //=============================================================================
161 void DoCreateDbFile()
163 TUint32 fc1 = User::FastCounter();
164 TInt err = TheDb.Create(TheDbFileName, &TheSqlConfigString);
167 if(err == KErrAlreadyExists)
169 err = TheDb.Open(TheDbFileName, &TheSqlConfigString);
172 TUint32 fc2 = User::FastCounter();
173 TheCreateDbCreateConnTime += TimeDiffUs(fc1, fc2);
179 TUint32 fc2 = User::FastCounter();
180 TheCreateDbOpenConnTime += TimeDiffUs(fc1, fc2);
182 TEST2(err, KErrNone);
185 void DoGetlastItemId()
187 _LIT(KGetLastMaxId, "SELECT max(seq) FROM SQLITE_SEQUENCE WHERE name!='symbian_security';");
188 TUint32 fc1 = User::FastCounter();
190 TInt err = stmt.Prepare(TheDb, KGetLastMaxId);
196 TUint32 fc2 = User::FastCounter();
197 TheLastItemIdTime += TimeDiffUs(fc1, fc2);
200 TBool MdePreferencesCheck()
202 _LIT(KCheck, "SELECT COUNT(*) FROM MdE_Preferences;");
203 TUint32 fc1 = User::FastCounter();
205 TInt err = stmt.Prepare(TheDb, KCheck);
211 TUint32 fc2 = User::FastCounter();
212 TheTableExistsTime += TimeDiffUs(fc1, fc2);
213 return err == KSqlAtRow;
216 void CreateMdeTables()
218 _LIT(KSql1, "CREATE TABLE MdE_Preferences(Key TEXT,Value NONE,ExtraValue LARGEINT,UNIQUE(Key,Value))");
219 _LIT(KSql2, "CREATE TABLE MdS_Medias(MediaId INTEGER PRIMARY KEY,Drive INTEGER,PresentState INTEGER,Time LARGEINT)");
220 _LIT(KSql3, "INSERT INTO MdE_Preferences(Key, Value, ExtraValue) VALUES(?, ?, ?)");
222 TUint32 fc1 = User::FastCounter();
224 TInt rc = TheDb.Exec(KSql1);
226 rc = TheDb.Exec(KSql2);
230 rc = stmt.Prepare(TheDb, KSql3);
232 rc = stmt.BindInt(0, 1);
234 rc = stmt.BindInt(1, 2);
236 rc = stmt.BindInt(2, 3);
242 TUint32 fc2 = User::FastCounter();
243 TheMdeTablesCreationTime += TimeDiffUs(fc1, fc2);
246 TInt64 LastInsertedRowId()
248 _LIT(KSql, "SELECT last_insert_rowid();");
249 TUint32 fc1 = User::FastCounter();
251 TInt err = stmt.Prepare(TheDb, KSql);
252 TEST2(err, KErrNone);
254 TEST2(err, KSqlAtRow);
255 TInt64 rowid = stmt.ColumnInt64(0);
257 TUint32 fc2 = User::FastCounter();
258 TheLastInsertedRowIdTime += TimeDiffUs(fc1, fc2);
262 void DoCreateTables1()
264 _LIT(KSql1, "CREATE TABLE IF NOT EXISTS NamespaceDef(NamespaceDefId INTEGER PRIMARY KEY,ReadOnly INTEGER,VendorId INTEGER,Name TEXT)");
265 _LIT(KSql2, "CREATE TABLE IF NOT EXISTS ObjectDef(ObjectDefId INTEGER PRIMARY KEY,NamespaceDefId INTEGER NOT NULL,ParentDefId INTEGER NOT NULL,Flags INTEGER,Name TEXT)");
266 _LIT(KSql3, "CREATE TABLE IF NOT EXISTS PropertyDef(PropertyDefId INTEGER PRIMARY KEY,ObjectDefId INTEGER NOT NULL,Flags INTEGER,Type INTEGER,MinValue NUMERIC,MaxValue NUMERIC,Name TEXT)");
267 _LIT(KSql4, "CREATE TABLE IF NOT EXISTS RelationDef(RelationDefId INTEGER PRIMARY KEY,NamespaceDefId INTEGER NOT NULL,Name TEXT)");
268 _LIT(KSql5, "CREATE TABLE IF NOT EXISTS EventDef(EventDefId INTEGER PRIMARY KEY,NamespaceDefId INTEGER NOT NULL,Priority INTEGER,Name TEXT)");
270 TUint32 fc1 = User::FastCounter();
272 TInt rc = TheDb.Exec(KSql1);
274 rc = TheDb.Exec(KSql2);
276 rc = TheDb.Exec(KSql3);
278 rc = TheDb.Exec(KSql4);
280 rc = TheDb.Exec(KSql5);
283 _LIT(KSql6, "INSERT INTO NamespaceDef(ReadOnly,VendorId,Name) Values(?,?,?);");
285 rc = stmt.Prepare(TheDb, KSql6);
287 rc = stmt.BindInt(0, 1);
289 rc = stmt.BindInt(1, 2);
291 rc = stmt.BindText(2, _L("Nokia"));
297 TUint32 fc2 = User::FastCounter();
298 TheCreateTables1Time += TimeDiffUs(fc1, fc2);
301 void BeginTransaction()
303 TInt err = TheDb.Exec(_L("BEGIN"));
307 void CommitTransaction()
309 TInt err = TheDb.Exec(_L("COMMIT"));
313 void DoCreateTables2()
315 _LIT(KSql1, "CREATE TABLE IF NOT EXISTS Object1(ObjectId INTEGER PRIMARY KEY AUTOINCREMENT,ObjectDefId INTEGER NOT NULL,Flags INTEGER,MediaId LARGEINT,UsageCount LARGEINT DEFAULT 0,GuidHigh LARGEINT,GuidLow LARGEINT,URI TEXT NOT NULL COLLATE NOCASE,Origin INTEGER,Size LARGEINT,TimeOffset INTEGER,CreationDate LARGEINT,LastModifiedDate LARGEINT,ItemType TEXT,Title TEXT,UNIQUE(GuidHigh,GuidLow),UNIQUE(MediaId,URI))");
316 _LIT(KSql2, "CREATE TABLE IF NOT EXISTS Relations1(RelationId INTEGER PRIMARY KEY AUTOINCREMENT,Flags INTEGER,RelationDefId INTEGER NOT NULL,LeftObjectId INTEGER NOT NULL,RightObjectId INTEGER NOT NULL,Parameter INTEGER,GuidHigh LARGEINT,GuidLow LARGEINT,LastModifiedDate LARGEINT)");
317 _LIT(KSql3, "CREATE TRIGGER DeleteRelations1 BEFORE DELETE ON Object1 BEGIN DELETE FROM Relations1 WHERE LeftObjectId=OLD.ObjectId OR RightObjectId=OLD.ObjectId; END");
318 _LIT(KSql4, "CREATE TABLE IF NOT EXISTS Event1(EventId INTEGER PRIMARY KEY AUTOINCREMENT,ObjectId INTEGER NOT NULL, EventDefId INTEGER NOT NULL, Timestamp INTEGER NOT NULL, Source TEXT, Participant TEXT)");
319 _LIT(KSql5, "CREATE TRIGGER DeleteEvent1 BEFORE DELETE ON Object1 BEGIN DELETE FROM Event1 WHERE ObjectId=OLD.ObjectId; END");
320 _LIT(KSql6, "CREATE TABLE IF NOT EXISTS TextSearch1(WordId INTEGER NOT NULL,ObjectId INTEGER NOT NULL,Position INTEGER)");
321 _LIT(KSql7, "CREATE TRIGGER DeleteTextSearch1 BEFORE DELETE ON Object1 BEGIN DELETE FROM TextSearch1 WHERE ObjectId=OLD.ObjectId; END");
322 _LIT(KSql8, "CREATE INDEX FreetextWordIdIndex1 ON TextSearch1(WordId)");
323 _LIT(KSql9, "CREATE INDEX FreetextObjectIdIndex1 ON TextSearch1(ObjectId)");
324 _LIT(KSql10, "CREATE TABLE IF NOT EXISTS TextSearchDictionary1(WordId INTEGER PRIMARY KEY,Word TEXT NOT NULL)");
325 _LIT(KSql11, "CREATE TRIGGER InsertRelations1 INSERT ON Relations1 BEGIN UPDATE Object1 SET UsageCount = UsageCount + 1 WHERE ObjectId=NEW.LeftObjectId OR ObjectId=NEW.RightObjectId; END");
326 _LIT(KSql12, "CREATE TRIGGER UpdateRelations1 UPDATE OF LeftObjectId, RightObjectId ON Relations1 WHEN OLD.Flags=NEW.Flags BEGIN UPDATE Object1 SET UsageCount = UsageCount - 1 WHERE ObjectId=OLD.LeftObjectId OR ObjectId=OLD.RightObjectId; UPDATE Object1 SET UsageCount = UsageCount + 1 WHERE ObjectId=NEW.LeftObjectId OR ObjectId=NEW.RightObjectId; END");
327 _LIT(KSql13, "CREATE TRIGGER UpdateNotRemovedRelations1 UPDATE OF Flags ON Relations1 WHEN OLD.Flags!=NEW.Flags AND NOT NEW.Flags&3 BEGIN UPDATE Object1 SET UsageCount = UsageCount + 1 WHERE ObjectId=NEW.LeftObjectId OR ObjectId=NEW.RightObjectId; END");
328 _LIT(KSql14, "CREATE TRIGGER UpdateRemovedRelations1 UPDATE OF Flags ON Relations1 WHEN OLD.Flags!=NEW.Flags AND NEW.Flags&3 AND NOT OLD.Flags&3 BEGIN UPDATE Object1 SET UsageCount = UsageCount - 1 WHERE ObjectId=OLD.LeftObjectId OR ObjectId=OLD.RightObjectId; END");
329 _LIT(KSql15, "CREATE INDEX RelationsLeftObjectIdIndex1 ON Relations1(LeftObjectId)");
330 _LIT(KSql16, "CREATE INDEX RelationsRightObjectIdIndex1 ON Relations1(RightObjectId)");
331 _LIT(KSql17, "CREATE INDEX ObjectDefIndex1 ON Object1(ObjectDefId)");
332 _LIT(KSql18, "CREATE TABLE IF NOT EXISTS Location1(ObjectId INTEGER NOT NULL,CellID LARGEINT,LocationAreaCode LARGEINT,Speed REAL,Direction REAL,Quality REAL,Latitude REAL,Longitude REAL,Altitude REAL,CountryCodeStr TEXT,NetworkCodeStr TEXT,Satellites TEXT,Country TEXT,CellName TEXT, UNIQUE(ObjectId))");
333 _LIT(KSql19, "CREATE TABLE IF NOT EXISTS Calendar1(ObjectId INTEGER NOT NULL,CalendarType INTEGER,LocalUid LARGEINT,StartTime LARGEINT,EndTime LARGEINT,Location TEXT,vCalendar TEXT, UNIQUE(ObjectId))");
334 _LIT(KSql20, "CREATE TABLE IF NOT EXISTS Contact1(ObjectId INTEGER NOT NULL,Number TEXT,EmailAddress TEXT,Company TEXT,JobTitle TEXT,Address TEXT,ContactURL TEXT,vCard TEXT, UNIQUE(ObjectId))");
335 _LIT(KSql21, "CREATE TABLE IF NOT EXISTS Message1(ObjectId INTEGER NOT NULL,Received INTEGER,ToWhom TEXT,Sender TEXT, UNIQUE(ObjectId))");
336 _LIT(KSql22, "CREATE TABLE IF NOT EXISTS Album1(ObjectId INTEGER NOT NULL,Ordered INTEGER,Type INTEGER, UNIQUE(ObjectId))");
337 _LIT(KSql23, "CREATE TABLE IF NOT EXISTS Tag1(ObjectId INTEGER NOT NULL, UNIQUE(ObjectId))");
338 _LIT(KSql24, "CREATE TABLE IF NOT EXISTS MediaObject1(ObjectId INTEGER NOT NULL,Protected INTEGER,DRM INTEGER,ThumbnailPresent INTEGER,Resized INTEGER,Sample INTEGER,Rating INTEGER,Privacy INTEGER,ResolutionUnit INTEGER,Bitrate INTEGER,Width INTEGER,Height INTEGER,Preinstalled INTEGER,AccessCount LARGEINT,DownloadID LARGEINT,Duration REAL,ReleaseDate LARGEINT,CaptureDate LARGEINT,Artist TEXT,Author TEXT,Copyright TEXT,Legal TEXT,Description TEXT,Comment TEXT,Genre TEXT, UNIQUE(ObjectId))");
339 _LIT(KSql25, "CREATE TABLE IF NOT EXISTS Video1(ObjectId INTEGER NOT NULL,Protected INTEGER,DRM INTEGER,ThumbnailPresent INTEGER,Resized INTEGER,Sample INTEGER,Rating INTEGER,Privacy INTEGER,ResolutionUnit INTEGER,Bitrate INTEGER,Width INTEGER,Height INTEGER,Preinstalled INTEGER,AccessCount LARGEINT,DownloadID LARGEINT,Duration REAL,ReleaseDate LARGEINT,CaptureDate LARGEINT,AgeProfile INTEGER,AudioFourCC LARGEINT,RecordingFlags LARGEINT,LastPlayPosition REAL,Framerate REAL,Artist TEXT,Author TEXT,Copyright TEXT,Legal TEXT,Description TEXT,Comment TEXT,Genre TEXT,AudioLanguage TEXT, UNIQUE(ObjectId))");
340 _LIT(KSql26, "CREATE TABLE IF NOT EXISTS Image1(ObjectId INTEGER NOT NULL,Protected INTEGER,DRM INTEGER,ThumbnailPresent INTEGER,Resized INTEGER,Sample INTEGER,Rating INTEGER,Privacy INTEGER,ResolutionUnit INTEGER,Bitrate INTEGER,Width INTEGER,Height INTEGER,Preinstalled INTEGER,AccessCount LARGEINT,DownloadID LARGEINT,Duration REAL,ReleaseDate LARGEINT,CaptureDate LARGEINT,FocalPlaneResolutionUnit INTEGER,ExposureProgram INTEGER,FocalLengthIn35mmFilm INTEGER,ISOSpeedRatings INTEGER,MeteringMode INTEGER,WhiteBalance INTEGER,Flash INTEGER,ColourSpace INTEGER,Orientation INTEGER,SamplesPerPixel INTEGER,BitsPerSample INTEGER,YCbCrPositioning INTEGER,ThumbCompression INTEGER,ThumbResolutionUnit INTEGER,ThumbOrientation INTEGER,FrameCount INTEGER,PixelXDimension LARGEINT,PixelYDimension LARGEINT,ExifVersion LARGEINT,ComponentsConfiguration LARGEINT,FlashPixVersion LARGEINT,ThumbXResolution LARGEINT,ThumbYResolution LARGEINT,FocalPlaneXResolution REAL,FocalPlaneYResolution REAL,ExposureTime REAL,ExposureBiasValue REAL,FNumber REAL,FocalLength REAL,ApertureValue REAL,MaxAperture REAL,ShutterSpeedValue REAL,XResolution REAL,YResolution REAL,DateTime LARGEINT,DateTimeDigitized LARGEINT,DateTimeOriginal LARGEINT,Artist TEXT,Author TEXT,Copyright TEXT,Legal TEXT,Description TEXT,Comment TEXT,Genre TEXT,Model TEXT,Make TEXT,RelatedSoundFile TEXT, UNIQUE(ObjectId))");
341 _LIT(KSql27, "CREATE TABLE IF NOT EXISTS Audio1(ObjectId INTEGER NOT NULL,Protected INTEGER,DRM INTEGER,ThumbnailPresent INTEGER,Resized INTEGER,Sample INTEGER,Rating INTEGER,Privacy INTEGER,ResolutionUnit INTEGER,Bitrate INTEGER,Width INTEGER,Height INTEGER,Preinstalled INTEGER,AccessCount LARGEINT,DownloadID LARGEINT,Duration REAL,ReleaseDate LARGEINT,CaptureDate LARGEINT,Track INTEGER,SamplingFrequency REAL,Artist TEXT,Author TEXT,Copyright TEXT,Legal TEXT,Description TEXT,Comment TEXT,Genre TEXT,Album TEXT,Composer TEXT,OriginalArtist TEXT,AlbumArtist TEXT, UNIQUE(ObjectId))");
342 _LIT(KSql28, "CREATE TABLE IF NOT EXISTS TrackLog1(ObjectId INTEGER NOT NULL,Length LARGEINT,StartTime LARGEINT,StopTime LARGEINT, UNIQUE(ObjectId))");
346 KSql1(), KSql2(), KSql3(), KSql4(), KSql5(), KSql6(), KSql7(), KSql8(), KSql9(), KSql10(),
347 KSql11(), KSql12(), KSql13(), KSql14(), KSql15(), KSql16(), KSql17(), KSql18(), KSql19(), KSql20(),
348 KSql21(), KSql22(), KSql23(), KSql24(), KSql25(), KSql26(), KSql27(), KSql28()
351 TUint32 fc1 = User::FastCounter();
352 for(TInt i=0;i<(sizeof(KSql)/sizeof(KSql[0]));++i)
354 TInt err = TheDb.Exec(KSql[i]);
357 TUint32 fc2 = User::FastCounter();
358 TheCreateTables2Time += TimeDiffUs(fc1, fc2);
361 void DoCreateTables3()
363 const TInt KInsObjDefRecCnt = 12;
364 const TInt KInsPropDefRecCnt[KInsObjDefRecCnt] = {7, 11, 6, 7, 3, 2, 0, 24, 6, 40, 6, 3};
365 TUint32 fc1 = User::FastCounter();
366 for(TInt i=0;i<KInsObjDefRecCnt;++i)
370 TInt err = stmt1.Prepare(TheDb, _L("INSERT INTO ObjectDef(NamespaceDefId, ParentDefId, Flags, Name) Values(?,?,?,?)"));
371 TEST2(err, KErrNone);
372 err = stmt1.BindInt(0, 1);
373 TEST2(err, KErrNone);
374 err = stmt1.BindInt(1, 2);
375 TEST2(err, KErrNone);
376 err = stmt1.BindInt(2, 3);
377 TEST2(err, KErrNone);
378 objDefName.Copy(_L("ObjDef"));
379 objDefName.AppendNum(i + 1);
380 err = stmt1.BindText(3, objDefName);
381 TEST2(err, KErrNone);
385 TInt64 objdefid = LastInsertedRowId();
386 for(TInt j=0;j<KInsPropDefRecCnt[i];++j)
388 TBuf<10> propDefName;
390 err = stmt2.Prepare(TheDb, _L("INSERT INTO PropertyDef(ObjectDefId,Flags,Type,MinValue,MaxValue,Name) Values(?,?,?,?,?,?);"));
391 TEST2(err, KErrNone);
392 err = stmt2.BindInt64(0, objdefid);
393 TEST2(err, KErrNone);
394 err = stmt2.BindInt(1, 2);
395 TEST2(err, KErrNone);
396 err = stmt2.BindInt(2, 3);
397 TEST2(err, KErrNone);
398 err = stmt2.BindInt(3, 100);
399 TEST2(err, KErrNone);
400 err = stmt2.BindInt(4, 200);
401 TEST2(err, KErrNone);
402 propDefName.Copy(_L("PropDef"));
403 propDefName.AppendNum(j + 1);
404 err = stmt2.BindText(5, propDefName);
405 TEST2(err, KErrNone);
412 TUint32 fc2 = User::FastCounter();
413 TheCreateTables3Time += TimeDiffUs(fc1, fc2);
416 void DoCreateTriggers()
418 _LIT(KSql1, "CREATE TRIGGER DeleteLocation1 DELETE ON Object1 BEGIN DELETE FROM Location1 WHERE ObjectId=OLD.ObjectId; END");
419 _LIT(KSql2, "CREATE TRIGGER DeleteCalendar1 DELETE ON Object1 BEGIN DELETE FROM Calendar1 WHERE ObjectId=OLD.ObjectId; END");
420 _LIT(KSql3, "CREATE TRIGGER DeleteContact1 DELETE ON Object1 BEGIN DELETE FROM Contact1 WHERE ObjectId=OLD.ObjectId; END");
421 _LIT(KSql4, "CREATE TRIGGER DeleteMessage1 DELETE ON Object1 BEGIN DELETE FROM Message1 WHERE ObjectId=OLD.ObjectId; END");
422 _LIT(KSql5, "CREATE TRIGGER DeleteAlbum1 DELETE ON Object1 BEGIN DELETE FROM Album1 WHERE ObjectId=OLD.ObjectId; END");
423 _LIT(KSql6, "CREATE TRIGGER DeleteTag1 DELETE ON Object1 BEGIN DELETE FROM Tag1 WHERE ObjectId=OLD.ObjectId; END");
424 _LIT(KSql7, "CREATE TRIGGER DeleteMediaObject1 DELETE ON Object1 BEGIN DELETE FROM MediaObject1 WHERE ObjectId=OLD.ObjectId; END");
425 _LIT(KSql8, "CREATE TRIGGER DeleteVideo1 DELETE ON Object1 BEGIN DELETE FROM Video1 WHERE ObjectId=OLD.ObjectId; END");
426 _LIT(KSql9, "CREATE TRIGGER DeleteImage1 DELETE ON Object1 BEGIN DELETE FROM Image1 WHERE ObjectId=OLD.ObjectId; END");
427 _LIT(KSql10, "CREATE TRIGGER DeleteAudio1 DELETE ON Object1 BEGIN DELETE FROM Audio1 WHERE ObjectId=OLD.ObjectId; END");
428 _LIT(KSql11, "CREATE TRIGGER DeleteTrackLog1 DELETE ON Object1 BEGIN DELETE FROM TrackLog1 WHERE ObjectId=OLD.ObjectId; END");
432 KSql1(), KSql2(), KSql3(), KSql4(), KSql5(), KSql6(), KSql7(), KSql8(), KSql9(), KSql10(), KSql11()
435 TUint32 fc1 = User::FastCounter();
436 for(TInt i=0;i<(sizeof(KSql)/sizeof(KSql[0]));++i)
438 TInt err = TheDb.Exec(KSql[i]);
441 TUint32 fc2 = User::FastCounter();
442 TheCreateTriggersTime += TimeDiffUs(fc1, fc2);
445 void DoInsertEventRelationDefs()
447 _LIT(KSql1, "INSERT INTO EventDef (NamespaceDefId, Priority, Name ) Values(?, ?, ?);");
448 const TInt KSql1Cnt = 7;
449 _LIT(KSql2, "INSERT INTO RelationDef (NamespaceDefId,Name) Values(?,?);");
450 const TInt KSql2Cnt = 8;
452 TUint32 fc1 = User::FastCounter();
454 for(TInt i=0;i<KSql1Cnt;++i)
456 TBuf<10> eventDefName;
458 TInt err = stmt.Prepare(TheDb, KSql1);
459 TEST2(err, KErrNone);
460 err = stmt.BindInt(0, 1);
461 TEST2(err, KErrNone);
462 err = stmt.BindInt(1, 2);
463 TEST2(err, KErrNone);
464 eventDefName.Copy(_L("EvtDef"));
465 eventDefName.AppendNum(i + 1);
466 err = stmt.BindText(2, eventDefName);
467 TEST2(err, KErrNone);
474 for(TInt i=0;i<KSql2Cnt;++i)
478 TInt err = stmt.Prepare(TheDb, KSql2);
479 TEST2(err, KErrNone);
480 err = stmt.BindInt(0, 1);
481 TEST2(err, KErrNone);
482 relDefName.Copy(_L("RelDef"));
483 relDefName.AppendNum(i + 1);
484 err = stmt.BindText(1, relDefName);
485 TEST2(err, KErrNone);
492 TUint32 fc2 = User::FastCounter();
493 TheInsertEventRelationTime += TimeDiffUs(fc1, fc2);
496 void DoDeleteObjPropertyDef()
498 _LIT(KSql1, "DELETE FROM ObjectDef WHERE ObjectDefId=?;");
499 _LIT(KSql2, "DELETE FROM PropertyDef WHERE ObjectDefId=?;");
501 TUint32 fc1 = User::FastCounter();
504 TInt err = stmt1.Prepare(TheDb, KSql1);
505 TEST2(err, KErrNone);
506 err = stmt1.BindInt(0, 0);
507 TEST2(err, KErrNone);
513 err = stmt2.Prepare(TheDb, KSql2);
514 TEST2(err, KErrNone);
515 err = stmt2.BindInt(0, 0);
516 TEST2(err, KErrNone);
521 TUint32 fc2 = User::FastCounter();
522 TheDeleteObjPropertyTime += TimeDiffUs(fc1, fc2);
525 void DoInsertCol2Prop()
527 _LIT(KSql1, "CREATE TABLE IF NOT EXISTS Col2Prop(ObjectDefId INTEGER NOT NULL,PropertyDefId INTEGER NOT NULL,ColumnId INTEGER NOT NULL)");
528 TInt KCol2PropCnt = KItemCnt;
529 _LIT(KSql2, "INSERT INTO Col2Prop(ObjectDefId,PropertyDefId,ColumnId) Values(?,?,?);");
531 TUint32 fc1 = User::FastCounter();
533 TInt err = TheDb.Exec(KSql1);
535 for(TInt i=0;i<KCol2PropCnt;++i)
538 err = stmt.Prepare(TheDb, KSql2);
539 TEST2(err, KErrNone);
540 err = stmt.BindInt(0, 10);
541 TEST2(err, KErrNone);
542 err = stmt.BindInt(1, 20);
543 TEST2(err, KErrNone);
544 err = stmt.BindInt(2, i);
545 TEST2(err, KErrNone);
551 TUint32 fc2 = User::FastCounter();
552 TheInsertCol2PropTime += TimeDiffUs(fc1, fc2);
556 @SYMTestCaseID PDS-SQL-UT-4149
557 @SYMTestCaseDesc MDE database creation performance test.
558 The test creates the MDE database using the SQL statements from the
559 production code of the MetaDataEngine server. The time taken for the execution of
560 SQL statements is measured and printed out.
561 @SYMTestActions MDE database creation performance test.
562 @SYMTestExpectedResults Test must not fail
563 @SYMTestPriority High
572 TUint32 fc1 = User::FastCounter();
574 ////////////////////////////////
576 MdePreferencesCheck();
578 ////////////////////////////////
579 TUint32 fc2 = User::FastCounter();
586 DoInsertEventRelationDefs();
587 DoDeleteObjPropertyDef();
591 TUint32 fc3 = User::FastCounter();
592 TheTransactionTime += TimeDiffUs(fc2, fc3);
593 TheDbCreateTime += TimeDiffUs(fc1, fc3);
596 void DoHarvestSelect()
598 TUint32 fc1 = User::FastCounter();
599 for(TInt i=0;i<TheIterationsCount;++i)
602 for(TInt j=0;j<TheIterations[i];++j)
604 _LIT(KSql, "SELECT ObjectId, Flags, LastModifiedDate, Size FROM Object1 WHERE NOT Flags&? AND (Flags&? OR Flags&?) AND MediaId=? AND URI=?;");
606 TInt err = stmt.Prepare(TheDb, KSql);
607 TEST2(err, KErrNone);
608 err = stmt.BindInt(0, 8);
609 TEST2(err, KErrNone);
610 err = stmt.BindInt(1, 16);
611 TEST2(err, KErrNone);
612 err = stmt.BindInt(2, 32);
613 TEST2(err, KErrNone);
615 media.Copy(_L("media"));
616 media.AppendNum(j + 1);
617 err = stmt.BindText(3, media);
618 TEST2(err, KErrNone);
621 uri.AppendNum(j + 1);
622 err = stmt.BindText(4, uri);
623 TEST2(err, KErrNone);
624 while((err = stmt.Next()) == KSqlAtRow)
627 TEST2(err, KSqlAtEnd);
632 TUint32 fc2 = User::FastCounter();
633 TheHarvestSelectTime += TimeDiffUs(fc1, fc2);
636 void DoHarvestInsertObjImage()
638 _LIT(KSql1, "INSERT INTO Object1(ObjectId,ObjectDefId,Flags,MediaId,GuidHigh,GuidLow,URI,Origin,Size,CreationDate,LastModifiedDate) VALUES(?,?,?,?,?,?,?,?,?,?,?);");
639 _LIT(KSql2, "INSERT INTO Image1(ObjectId) VALUES(?);");
641 TUint32 fc1 = User::FastCounter();
643 for(TInt i=0;i<TheIterationsCount;++i)
646 for(TInt j=0;j<TheIterations[i];++j)
650 TInt err = stmt1.Prepare(TheDb, KSql1);
651 TEST2(err, KErrNone);
652 err = stmt1.BindInt(0, objdef);
653 TEST2(err, KErrNone);
654 err = stmt1.BindInt(1, 9);
655 TEST2(err, KErrNone);
656 err = stmt1.BindInt(2, 48);
657 TEST2(err, KErrNone);
658 err = stmt1.BindInt(3, 3);
659 TEST2(err, KErrNone);
660 err = stmt1.BindInt(4, j + 1 + i * 100);
661 TEST2(err, KErrNone);
662 err = stmt1.BindInt(5, j + 1 + i * 10000);
663 TEST2(err, KErrNone);
665 uri.Copy(_L("URI-"));
666 uri.AppendNum(j + 1 + i * 100);
667 err = stmt1.BindText(6, uri);
668 TEST2(err, KErrNone);
669 err = stmt1.BindInt(7, 0);
670 TEST2(err, KErrNone);
671 err = stmt1.BindInt(8, 1000000);
672 TEST2(err, KErrNone);
673 err = stmt1.BindInt64(9, 32324234218723LL);
674 TEST2(err, KErrNone);
675 err = stmt1.BindInt64(10, 5675069785676565LL);
676 TEST2(err, KErrNone);
682 err = stmt2.Prepare(TheDb, KSql2);
683 TEST2(err, KErrNone);
684 err = stmt2.BindInt(0, objdef);
685 TEST2(err, KErrNone);
692 TUint32 fc2 = User::FastCounter();
693 TheHarvestInsertObjImageTime += TimeDiffUs(fc1, fc2);
696 void DoHarvestSelect2()
698 TUint32 fc1 = User::FastCounter();
699 ///////////////////////////////////////////////////////////////////////
700 _LIT(KSql1, "SELECT count(*) FROM Object1 AS BO WHERE(NOT Flags&?)AND (NOT Flags&?) AND (((BO.ObjectId IN(SELECT ObjectId FROM Object1 WHERE((NOT Flags&?)AND (NOT Flags&?)AND (NOT Flags&?)AND ObjectDefId=?))OR BO.ObjectId IN(SELECT ObjectId FROM Object1 WHERE((NOT Flags&?)AND (NOT Flags&?)AND (NOT Flags&?)AND ObjectDefId=?)))AND BO.ObjectId IN(SELECT ObjectId FROM Object1 WHERE(Origin=?)))) ORDER BY LastModifiedDate DESC,BO.ObjectId DESC ;");
702 TInt err = stmt1.Prepare(TheDb, KSql1);
703 TEST2(err, KErrNone);
704 err = stmt1.BindInt(0, 8);
705 TEST2(err, KErrNone);
706 err = stmt1.BindInt(1, 16);
707 TEST2(err, KErrNone);
708 err = stmt1.BindInt(2, 32);
709 TEST2(err, KErrNone);
710 err = stmt1.BindInt(3, 64);
711 TEST2(err, KErrNone);
712 err = stmt1.BindInt(4, 128);
713 TEST2(err, KErrNone);
714 err = stmt1.BindInt(5, 1);
715 TEST2(err, KErrNone);
716 err = stmt1.BindInt(6, 8);
717 TEST2(err, KErrNone);
718 err = stmt1.BindInt(7, 16);
719 TEST2(err, KErrNone);
720 err = stmt1.BindInt(8, 32);
721 TEST2(err, KErrNone);
722 err = stmt1.BindInt(9, 1);
723 TEST2(err, KErrNone);
724 err = stmt1.BindInt(10, 1);
725 TEST2(err, KErrNone);
726 while((err = stmt1.Next()) == KSqlAtRow)
729 TEST2(err, KSqlAtEnd);
731 ///////////////////////////////////////////////////////////////////////
732 _LIT(KSql2, "SELECT count(*) FROM Object1 AS BO WHERE(NOT Flags&?)AND (NOT Flags&?)AND ((BO.ObjectId IN(SELECT ObjectId FROM Object1 WHERE(Origin=?)))) ORDER BY CreationDate DESC,BO.ObjectId DESC ;");
734 err = stmt2.Prepare(TheDb, KSql2);
735 TEST2(err, KErrNone);
736 err = stmt2.BindInt(0, 8);
737 TEST2(err, KErrNone);
738 err = stmt2.BindInt(1, 16);
739 TEST2(err, KErrNone);
740 err = stmt2.BindInt(2, 1);
741 TEST2(err, KErrNone);
742 while((err = stmt2.Next()) == KSqlAtRow)
745 TEST2(err, KSqlAtEnd);
747 ///////////////////////////////////////////////////////////////////////
748 _LIT(KSql3, "SELECT BO.* FROM Object1 AS BO WHERE(NOT Flags&?)AND (NOT Flags&?)AND ((BO.ObjectId IN(SELECT ObjectId FROM Object1 WHERE(Origin=?)))) ORDER BY CreationDate ASC,BO.ObjectId ASC ;");
750 err = stmt3.Prepare(TheDb, KSql3);
751 TEST2(err, KErrNone);
752 err = stmt3.BindInt(0, 8);
753 TEST2(err, KErrNone);
754 err = stmt3.BindInt(1, 16);
755 TEST2(err, KErrNone);
756 err = stmt3.BindInt(2, 1);
757 TEST2(err, KErrNone);
758 while((err = stmt3.Next()) == KSqlAtRow)
761 TEST2(err, KSqlAtEnd);
763 /////////////////////////////////////////////////////////////////////////
764 _LIT(KSql4, "SELECT count(*) FROM Object1 AS BO ,Album1 AS O ON BO.ObjectId=O.ObjectId WHERE(NOT Flags&?)AND (NOT Flags&?) ORDER BY Title COLLATE NOCASE ASC ;");
766 err = stmt4.Prepare(TheDb, KSql4);
767 TEST2(err, KErrNone);
768 err = stmt4.BindInt(0, 8);
769 TEST2(err, KErrNone);
770 err = stmt4.BindInt(1, 16);
771 TEST2(err, KErrNone);
772 while((err = stmt4.Next()) == KSqlAtRow)
775 TEST2(err, KSqlAtEnd);
777 ///////////////////////////////////////////////////////////////////////////
778 _LIT(KSql5, "SELECT count(*) FROM Object1 AS BO WHERE(NOT Flags&?)AND (NOT Flags&?)AND (((BO.ObjectId IN(SELECT ObjectId FROM Object1 WHERE((NOT Flags&?)AND (NOT Flags&?)AND (NOT Flags&?)AND ObjectDefId=?))OR BO.ObjectId IN(SELECT ObjectId FROM Object1 WHERE((NOT Flags&?)AND (NOT Flags&?)AND (NOT Flags&?)AND ObjectDefId=?)))AND BO.ObjectId IN(SELECT ObjectId FROM Object1 WHERE(Origin!=?)))) ORDER BY CreationDate DESC,BO.ObjectId DESC ;");
780 err = stmt5.Prepare(TheDb, KSql5);
781 TEST2(err, KErrNone);
782 err = stmt5.BindInt(0, 8);
783 TEST2(err, KErrNone);
784 err = stmt5.BindInt(1, 16);
785 TEST2(err, KErrNone);
786 err = stmt5.BindInt(2, 32);
787 TEST2(err, KErrNone);
788 err = stmt5.BindInt(3, 64);
789 TEST2(err, KErrNone);
790 err = stmt5.BindInt(4, 128);
791 TEST2(err, KErrNone);
792 err = stmt5.BindInt(5, 1);
793 TEST2(err, KErrNone);
794 err = stmt5.BindInt(6, 8);
795 TEST2(err, KErrNone);
796 err = stmt5.BindInt(7, 16);
797 TEST2(err, KErrNone);
798 err = stmt5.BindInt(8, 32);
799 TEST2(err, KErrNone);
800 err = stmt5.BindInt(9, 1);
801 TEST2(err, KErrNone);
802 err = stmt5.BindInt(10, 1);
803 TEST2(err, KErrNone);
804 while((err = stmt5.Next()) == KSqlAtRow)
807 TEST2(err, KSqlAtEnd);
809 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
810 _LIT(KSql6, "SELECT count(*) FROM Object1 AS BO ,Tag1 AS O ON BO.ObjectId=O.ObjectId WHERE(NOT Flags&?)AND (NOT Flags&?)AND ((O.ObjectId IN(SELECT ObjectId FROM Object1 WHERE((NOT Flags&?)AND (NOT Flags&?)AND (NOT Flags&?)AND UsageCount>=?)))) ORDER BY Title COLLATE NOCASE ASC ;");
812 err = stmt6.Prepare(TheDb, KSql6);
813 TEST2(err, KErrNone);
814 err = stmt6.BindInt(0, 8);
815 TEST2(err, KErrNone);
816 err = stmt6.BindInt(1, 16);
817 TEST2(err, KErrNone);
818 err = stmt6.BindInt(2, 32);
819 TEST2(err, KErrNone);
820 err = stmt6.BindInt(3, 64);
821 TEST2(err, KErrNone);
822 err = stmt6.BindInt(4, 128);
823 TEST2(err, KErrNone);
824 err = stmt6.BindInt(5, 1);
825 TEST2(err, KErrNone);
826 while((err = stmt6.Next()) == KSqlAtRow)
829 TEST2(err, KSqlAtEnd);
832 TUint32 fc2 = User::FastCounter();
833 TheHarvestSelect2Time += TimeDiffUs(fc1, fc2);
836 void DoHarvestInsertEvent()
838 TUint32 fc1 = User::FastCounter();
840 _LIT(KSql, "INSERT INTO Event1(EventId,ObjectId,EventDefId,Timestamp,Source,Participant) VALUES(?,?,?,?,?,?);");
841 const TInt KEventCnt = KItemCnt;
843 for(TInt i=0;i<KEventCnt;++i)
847 TInt err = stmt.Prepare(TheDb, KSql);
848 TEST2(err, KErrNone);
849 err = stmt.BindInt(0, i + 1);
850 TEST2(err, KErrNone);
851 err = stmt.BindInt(1, i + 1);
852 TEST2(err, KErrNone);
853 err = stmt.BindInt(2, i + 1);
854 TEST2(err, KErrNone);
855 err = stmt.BindInt64(3, 329231202230LL);
856 TEST2(err, KErrNone);
857 err = stmt.BindInt(4, 1);
858 TEST2(err, KErrNone);
859 err = stmt.BindInt(5, 367);
860 TEST2(err, KErrNone);
865 TUint32 fc2 = User::FastCounter();
866 TheHarvestInsertEventTime += TimeDiffUs(fc1, fc2);
869 void DoHarvestUpdateObjImage()
871 TUint32 fc1 = User::FastCounter();
873 _LIT(KSql1, "UPDATE Object1 SET Flags=? ,Origin=?,TimeOffset=?,ItemType=?,Title=? WHERE ObjectId=?;");
874 _LIT(KSql2, "UPDATE Image1 SET Width=?,Height=?,BitsPerSample=?,FrameCount=? WHERE ObjectId=?;");
876 for(TInt i=0;i<KItemCnt;++i)
881 TInt err = stmt1.Prepare(TheDb, KSql1);
882 TEST2(err, KErrNone);
883 err = stmt1.BindInt(0, 32);
884 TEST2(err, KErrNone);
885 err = stmt1.BindInt(1, 1);
886 TEST2(err, KErrNone);
887 err = stmt1.BindInt(2, 2);
888 TEST2(err, KErrNone);
889 err = stmt1.BindInt(3, 3);
890 TEST2(err, KErrNone);
892 title.Copy(_L("Title-"));
893 title.AppendNum(i + 1);
894 err = stmt1.BindText(4, title);
895 TEST2(err, KErrNone);
896 err = stmt1.BindInt(5, i + 1);
897 TEST2(err, KErrNone);
903 err = stmt2.Prepare(TheDb, KSql2);
904 TEST2(err, KErrNone);
905 err = stmt2.BindInt(0, 1000);
906 TEST2(err, KErrNone);
907 err = stmt2.BindInt(1, 1200);
908 TEST2(err, KErrNone);
909 err = stmt2.BindInt(2, 24);
910 TEST2(err, KErrNone);
911 err = stmt2.BindInt(3, 3);
912 TEST2(err, KErrNone);
913 err = stmt2.BindInt(4, i + 1);
914 TEST2(err, KErrNone);
922 TUint32 fc2 = User::FastCounter();
923 TheHarvestUpdateObjImageTime += TimeDiffUs(fc1, fc2);
926 void DoHarvestSelect3()
928 TUint32 fc1 = User::FastCounter();
930 _LIT(KSql1, "SELECT BO.* ,O.* FROM Object1 AS BO ,Image1 AS O ON BO.ObjectId=O.ObjectId WHERE(NOT Flags&?)AND (NOT Flags&?)AND ((O.ObjectId IN(SELECT ObjectId FROM Object1 WHERE((NOT Flags&?)AND (NOT Flags&?)AND ObjectId=?))))LIMIT 1;");
932 for(TInt i=0;i<KItemCnt;++i)
935 TInt err = stmt.Prepare(TheDb, KSql1);
936 TEST2(err, KErrNone);
937 err = stmt.BindInt(0, 65536);
938 TEST2(err, KErrNone);
939 err = stmt.BindInt(1, 65536);
940 TEST2(err, KErrNone);
941 err = stmt.BindInt(2, 65536);
942 TEST2(err, KErrNone);
943 err = stmt.BindInt(3, 65536);
944 TEST2(err, KErrNone);
945 err = stmt.BindInt(4, i + 1);
946 TEST2(err, KErrNone);
948 while((err = stmt.Next()) == KSqlAtRow)
952 TEST2(err, KSqlAtEnd);
957 TUint32 fc2 = User::FastCounter();
958 TheHarvestSelect3Time += TimeDiffUs(fc1, fc2);
961 void DoHarvestSelect4()
963 TUint32 fc1 = User::FastCounter();
965 _LIT(KSql2, "SELECT BO.* FROM Object1 AS BO WHERE(NOT Flags&?)AND (NOT Flags&?)AND ((BO.ObjectId IN(SELECT ObjectId FROM Object1 WHERE((NOT Flags&?)AND (NOT Flags&?)AND (NOT Flags&?)AND ObjectId=?))));");
967 for(TInt i=0;i<KItemCnt;++i)
970 TInt err = stmt.Prepare(TheDb, KSql2);
971 TEST2(err, KErrNone);
972 err = stmt.BindInt(0, 65536);
973 TEST2(err, KErrNone);
974 err = stmt.BindInt(1, 65536);
975 TEST2(err, KErrNone);
976 err = stmt.BindInt(2, 65536);
977 TEST2(err, KErrNone);
978 err = stmt.BindInt(3, 65536);
979 TEST2(err, KErrNone);
980 err = stmt.BindInt(4, 65536);
981 TEST2(err, KErrNone);
982 err = stmt.BindInt(5, i + 1);
983 TEST2(err, KErrNone);
985 while((err = stmt.Next()) == KSqlAtRow)
989 TEST2(err, KSqlAtEnd);
994 TUint32 fc2 = User::FastCounter();
995 TheHarvestSelect4Time += TimeDiffUs(fc1, fc2);
998 void DoHarvestUpdateObj()
1000 TUint32 fc1 = User::FastCounter();
1002 _LIT(KSql, "UPDATE Object1 SET Flags=Flags&? WHERE ObjectId IN(?);");
1004 for(TInt i=0;i<KItemCnt;++i)
1008 TInt err = stmt.Prepare(TheDb, KSql);
1009 TEST2(err, KErrNone);
1010 err = stmt.BindInt(0, 32768);
1011 TEST2(err, KErrNone);
1012 err = stmt.BindInt(1, i + 1);
1013 TEST2(err, KErrNone);
1017 CommitTransaction();
1020 TUint32 fc2 = User::FastCounter();
1021 TheHarvestUpdateObjTime += TimeDiffUs(fc1, fc2);
1026 TUint32 fc1 = User::FastCounter();
1028 DoHarvestInsertObjImage();
1032 DoHarvestInsertEvent();
1033 DoHarvestUpdateObjImage();
1036 DoHarvestUpdateObj();
1037 TUint32 fc2 = User::FastCounter();
1038 TheHarvestTime += TimeDiffUs(fc1, fc2);
1042 @SYMTestCaseID PDS-SQL-UT-4150
1043 @SYMTestCaseDesc MDS harvesting performance test.
1044 The test reproduces the MDS harvesting actions with the SQL server,
1045 performed for 1000 images. The time taken for the execution of SQL statements
1046 is measured and printed out.
1047 @SYMTestActions MDS harvesting performance test.
1048 @SYMTestExpectedResults Test must not fail
1049 @SYMTestPriority High
1054 TheTest.Printf(_L("==Fast counter frequency=%d Hz\r\n"), TheFastCounterFreq);
1055 TheTest.Printf(_L("==Create database, time=%d us\r\n"), TheCreateDbCreateConnTime);
1056 TheTest.Printf(_L("==Open database, time=%d us\r\n"), TheCreateDbOpenConnTime);
1057 TheTest.Printf(_L("=='SELECT max(seq) FROM SQLITE_SEQUENCE', time=%d us\r\n"), TheLastItemIdTime);
1058 TheTest.Printf(_L("=='SELECT COUNT(*) FROM MdE_Preferences', time=%d us\r\n"), TheTableExistsTime);
1059 TheTest.Printf(_L("==MDE tables creation, time=%d us\r\n"), TheMdeTablesCreationTime);
1060 TheTest.Printf(_L("=='SELECT last_insert_rowid()', time=%d us\r\n"), TheLastInsertedRowIdTime);
1061 TheTest.Printf(_L("==1.Create tables, time=%d us\r\n"), TheCreateTables1Time);
1062 TheTest.Printf(_L("==2.Create tables, time=%d us\r\n"), TheCreateTables2Time);
1063 TheTest.Printf(_L("==3.Create tables, time=%d us\r\n"), TheCreateTables3Time);
1064 TheTest.Printf(_L("==InsertEventRelation, time=%d us\r\n"), TheInsertEventRelationTime);
1065 TheTest.Printf(_L("==Create triggers, time=%d us\r\n"), TheCreateTriggersTime);
1066 TheTest.Printf(_L("==DeleteObjectProperty, time=%d us\r\n"), TheDeleteObjPropertyTime);
1067 TheTest.Printf(_L("==InsertCol2Property, time=%d us\r\n"), TheInsertCol2PropTime);
1068 TheTest.Printf(_L("==The create transaction, time=%d us\r\n"), TheTransactionTime);
1069 TheTest.Printf(_L("==Database create schema, time=%d us\r\n"), TheDbCreateTime);
1071 TheTest.Printf(_L("==HarvestSelect, time=%d us\r\n"), TheHarvestSelectTime);
1072 TheTest.Printf(_L("==HarvestInsertObjImage, time=%d us\r\n"), TheHarvestInsertObjImageTime);
1073 TheTest.Printf(_L("==HarvestSelect2, time=%d us\r\n"), TheHarvestSelect2Time);
1074 TheTest.Printf(_L("==HarvestSelect3, time=%d us\r\n"), TheHarvestSelect3Time);
1075 TheTest.Printf(_L("==HarvestSelect4, time=%d us\r\n"), TheHarvestSelect4Time);
1076 TheTest.Printf(_L("==HarvestInsertEvent, time=%d us\r\n"), TheHarvestInsertEventTime);
1077 TheTest.Printf(_L("==HarvestUpdateObjImage, time=%d us\r\n"), TheHarvestUpdateObjImageTime);
1078 TheTest.Printf(_L("==HarvestUpdateObj, time=%d us\r\n"), TheHarvestUpdateObjTime);
1079 TheTest.Printf(_L("==Harvest, time=%d us\r\n"), TheHarvestTime);
1084 CalcIterationsCount();
1086 TheTestTitle.Format(_L("@SYMTestCaseID:PDS-SQL-UT-4149 Create database, encoding: \"%S\", page size: %d\r\n"),
1087 TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
1088 TheTest.Start(TheTestTitle);
1091 TheTestTitle.Format(_L("@SYMTestCaseID:PDS-SQL-UT-4150 Harvest %d items, encoding: \"%S\", page size: %d\r\n"),
1092 KItemCnt, TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
1093 TheTest.Next(TheTestTitle);
1103 CTrapCleanup* tc = CTrapCleanup::New();
1104 TheTest(tc != NULL);
1108 GetCmdLineParamsAndSqlConfigString(TheTest, _L("t_sqlperformance3"), TheCmdLineParams, TheSqlConfigString);
1109 PrepareDbName(KDbName, TheCmdLineParams.iDriveName, TheDbFileName);
1111 TheTest.Printf(_L("==Databases: %S\r\n"), &TheDbFileName);
1115 TRAPD(err, DoTestsL());
1117 TEST2(err, KErrNone);
1126 User::Heap().Check();