os/persistentdata/persistentstorage/sql/TEST/t_sqlperformance3.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description: MDS harvesting performance test
sl@0
    14
//
sl@0
    15
#include <e32test.h>
sl@0
    16
#include <e32math.h>
sl@0
    17
#include <bautils.h>
sl@0
    18
#include <hal.h>
sl@0
    19
#include <sqldb.h>
sl@0
    20
#include "t_sqlcmdlineutil.h"
sl@0
    21
sl@0
    22
RTest 			TheTest(_L("t_sqlperformance3 test"));
sl@0
    23
RSqlDatabase 	TheDb;
sl@0
    24
sl@0
    25
_LIT(KDbName, 	"c:\\test\\t_sqlperformance3.db");
sl@0
    26
sl@0
    27
TFileName		TheDbFileName;
sl@0
    28
TBuf<200> 		TheTestTitle;
sl@0
    29
TCmdLineParams 	TheCmdLineParams(TCmdLineParams::EDbUtf16, 4096, 10000);
sl@0
    30
TBuf8<200> 		TheSqlConfigString;
sl@0
    31
sl@0
    32
_LIT(KUtf8,  "UTF8 ");
sl@0
    33
_LIT(KUtf16, "UTF16");
sl@0
    34
sl@0
    35
TInt TheFastCounterFreq = 0;
sl@0
    36
sl@0
    37
const TInt KItemCnt = 1000;
sl@0
    38
const TInt KItemBlockSize = 100;
sl@0
    39
sl@0
    40
TInt TheIterations[100];
sl@0
    41
TInt TheIterationsCount = -1;
sl@0
    42
sl@0
    43
void CalcIterationsCount()
sl@0
    44
	{
sl@0
    45
	TheIterationsCount = KItemCnt / KItemBlockSize;
sl@0
    46
	TInt r = KItemCnt % KItemBlockSize;
sl@0
    47
	if(r > 0)
sl@0
    48
		{
sl@0
    49
		++TheIterationsCount;		
sl@0
    50
		}
sl@0
    51
	else
sl@0
    52
		{
sl@0
    53
		r = KItemBlockSize;
sl@0
    54
		}
sl@0
    55
	for(TInt i=0;i<(TheIterationsCount-1);++i)
sl@0
    56
		{
sl@0
    57
		TheIterations[i] = KItemBlockSize;
sl@0
    58
		}
sl@0
    59
	TheIterations[TheIterationsCount - 1] = r;
sl@0
    60
	}
sl@0
    61
sl@0
    62
////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
    63
sl@0
    64
void TestEnvDestroy()
sl@0
    65
	{
sl@0
    66
	TheDb.Close();
sl@0
    67
	(void)RSqlDatabase::Delete(TheDbFileName);
sl@0
    68
	}
sl@0
    69
sl@0
    70
///////////////////////////////////////////////////////////////////////////////////////
sl@0
    71
///////////////////////////////////////////////////////////////////////////////////////
sl@0
    72
//Test macros and functions
sl@0
    73
void Check1(TInt aValue, TInt aLine)
sl@0
    74
	{
sl@0
    75
	if(!aValue)
sl@0
    76
		{
sl@0
    77
		TestEnvDestroy();
sl@0
    78
		TheTest.Printf(_L("*** Line %d\r\n"), aLine);
sl@0
    79
		TheTest(EFalse, aLine);
sl@0
    80
		}
sl@0
    81
	}
sl@0
    82
void Check2(TInt aValue, TInt aExpected, TInt aLine)
sl@0
    83
	{
sl@0
    84
	if(aValue != aExpected)
sl@0
    85
		{
sl@0
    86
		TSqlRetCodeClass cl = SqlRetCodeClass(aValue);
sl@0
    87
		if(cl == ESqlDbError)
sl@0
    88
			{
sl@0
    89
			TPtrC errmsg = TheDb.LastErrorMessage();
sl@0
    90
			TheTest.Printf(_L("*** SQLite err=\"%S\"\r\n"), &errmsg);
sl@0
    91
			}
sl@0
    92
		TestEnvDestroy();
sl@0
    93
		TheTest.Printf(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
sl@0
    94
		TheTest(EFalse, aLine);
sl@0
    95
		}
sl@0
    96
	}
sl@0
    97
#define TEST(arg) ::Check1((arg), __LINE__)
sl@0
    98
#define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
sl@0
    99
sl@0
   100
///////////////////////////////////////////////////////////////////////////////////////
sl@0
   101
sl@0
   102
void TestEnvInit()
sl@0
   103
	{
sl@0
   104
	RFs fs;
sl@0
   105
	TInt err = fs.Connect();
sl@0
   106
	TEST2(err, KErrNone);
sl@0
   107
	err = fs.MkDirAll(TheDbFileName);
sl@0
   108
	TEST(err == KErrNone || err == KErrAlreadyExists);
sl@0
   109
	fs.Close();
sl@0
   110
	}
sl@0
   111
sl@0
   112
TInt TimeDiffUs(TUint32 aStartTicks, TUint32 aEndTicks)
sl@0
   113
	{
sl@0
   114
	if(TheFastCounterFreq == 0)
sl@0
   115
		{
sl@0
   116
		TEST2(HAL::Get(HAL::EFastCounterFrequency, TheFastCounterFreq), KErrNone);
sl@0
   117
		}
sl@0
   118
	TInt64 diffTicks = (TInt64)aEndTicks - (TInt64)aStartTicks;
sl@0
   119
	if(diffTicks < 0)
sl@0
   120
		{
sl@0
   121
		diffTicks = KMaxTUint32 + diffTicks + 1;
sl@0
   122
		}
sl@0
   123
	const TInt KMicroSecIn1Sec = 1000000;
sl@0
   124
	TInt us = (diffTicks * KMicroSecIn1Sec) / TheFastCounterFreq;
sl@0
   125
	return us;
sl@0
   126
	}
sl@0
   127
sl@0
   128
void PrintTime(const TDesC& aFmt, TUint32 aStartTicks, TUint32 aEndTicks)
sl@0
   129
	{
sl@0
   130
	TInt us = TimeDiffUs(aStartTicks, aEndTicks);
sl@0
   131
	TheTest.Printf(aFmt, us);
sl@0
   132
	}
sl@0
   133
sl@0
   134
//=============================================================================
sl@0
   135
TInt TheCreateDbCreateConnTime = 0;
sl@0
   136
TInt TheCreateDbOpenConnTime = 0;
sl@0
   137
TInt TheLastItemIdTime = 0;
sl@0
   138
TInt TheTableExistsTime = 0;
sl@0
   139
TInt TheMdeTablesCreationTime = 0;
sl@0
   140
TInt TheLastInsertedRowIdTime = 0;
sl@0
   141
TInt TheCreateTables1Time = 0;
sl@0
   142
TInt TheCreateTables2Time = 0;
sl@0
   143
TInt TheCreateTables3Time = 0;
sl@0
   144
TInt TheTransactionTime = 0;
sl@0
   145
TInt TheDbCreateTime = 0;
sl@0
   146
TInt TheCreateTriggersTime = 0;
sl@0
   147
TInt TheInsertEventRelationTime = 0;
sl@0
   148
TInt TheDeleteObjPropertyTime = 0;
sl@0
   149
TInt TheInsertCol2PropTime = 0;
sl@0
   150
TInt TheHarvestTime = 0;
sl@0
   151
TInt TheHarvestSelectTime = 0;
sl@0
   152
TInt TheHarvestInsertObjImageTime = 0;
sl@0
   153
TInt TheHarvestSelect2Time = 0;
sl@0
   154
TInt TheHarvestInsertEventTime = 0;
sl@0
   155
TInt TheHarvestUpdateObjImageTime = 0;
sl@0
   156
TInt TheHarvestSelect3Time = 0;
sl@0
   157
TInt TheHarvestSelect4Time = 0;
sl@0
   158
TInt TheHarvestUpdateObjTime = 0;
sl@0
   159
//=============================================================================
sl@0
   160
sl@0
   161
void DoCreateDbFile()
sl@0
   162
	{
sl@0
   163
	TUint32 fc1 = User::FastCounter();
sl@0
   164
    TInt err = TheDb.Create(TheDbFileName, &TheSqlConfigString);
sl@0
   165
    if(err != KErrNone)
sl@0
   166
    	{
sl@0
   167
    	if(err == KErrAlreadyExists)
sl@0
   168
    		{
sl@0
   169
    		err = TheDb.Open(TheDbFileName, &TheSqlConfigString);
sl@0
   170
    		if(err == KErrNone)
sl@0
   171
    			{
sl@0
   172
    			TUint32 fc2 = User::FastCounter();
sl@0
   173
    			TheCreateDbCreateConnTime += TimeDiffUs(fc1, fc2);
sl@0
   174
    			}
sl@0
   175
    		}
sl@0
   176
    	}
sl@0
   177
    else
sl@0
   178
    	{
sl@0
   179
    	TUint32 fc2 = User::FastCounter();
sl@0
   180
		TheCreateDbOpenConnTime += TimeDiffUs(fc1, fc2);
sl@0
   181
    	}
sl@0
   182
    TEST2(err, KErrNone);
sl@0
   183
	}
sl@0
   184
sl@0
   185
void DoGetlastItemId()
sl@0
   186
	{
sl@0
   187
	_LIT(KGetLastMaxId, "SELECT max(seq) FROM SQLITE_SEQUENCE WHERE name!='symbian_security';");
sl@0
   188
	TUint32 fc1 = User::FastCounter();
sl@0
   189
	RSqlStatement stmt;
sl@0
   190
	TInt err = stmt.Prepare(TheDb, KGetLastMaxId);
sl@0
   191
	if(err == KErrNone)
sl@0
   192
		{
sl@0
   193
		(void)stmt.Next();
sl@0
   194
		}
sl@0
   195
	stmt.Close();
sl@0
   196
	TUint32 fc2 = User::FastCounter();
sl@0
   197
	TheLastItemIdTime += TimeDiffUs(fc1, fc2);
sl@0
   198
	}
sl@0
   199
sl@0
   200
TBool MdePreferencesCheck()
sl@0
   201
	{
sl@0
   202
	_LIT(KCheck, "SELECT COUNT(*) FROM MdE_Preferences;");
sl@0
   203
	TUint32 fc1 = User::FastCounter();
sl@0
   204
	RSqlStatement stmt;
sl@0
   205
	TInt err = stmt.Prepare(TheDb, KCheck);
sl@0
   206
	if(err == KErrNone)
sl@0
   207
		{
sl@0
   208
		err = stmt.Next();
sl@0
   209
		}
sl@0
   210
	stmt.Close();
sl@0
   211
	TUint32 fc2 = User::FastCounter();
sl@0
   212
	TheTableExistsTime += TimeDiffUs(fc1, fc2);
sl@0
   213
	return err == KSqlAtRow;
sl@0
   214
	}
sl@0
   215
sl@0
   216
void CreateMdeTables()
sl@0
   217
	{
sl@0
   218
	_LIT(KSql1, "CREATE TABLE MdE_Preferences(Key TEXT,Value NONE,ExtraValue LARGEINT,UNIQUE(Key,Value))");
sl@0
   219
	_LIT(KSql2, "CREATE TABLE MdS_Medias(MediaId INTEGER PRIMARY KEY,Drive INTEGER,PresentState INTEGER,Time LARGEINT)");
sl@0
   220
	_LIT(KSql3, "INSERT INTO MdE_Preferences(Key, Value, ExtraValue) VALUES(?, ?, ?)");
sl@0
   221
	
sl@0
   222
	TUint32 fc1 = User::FastCounter();
sl@0
   223
	
sl@0
   224
	TInt rc = TheDb.Exec(KSql1);
sl@0
   225
	TEST(rc >= 0);
sl@0
   226
	rc = TheDb.Exec(KSql2);
sl@0
   227
	TEST(rc >= 0);
sl@0
   228
	
sl@0
   229
	RSqlStatement stmt;
sl@0
   230
	rc = stmt.Prepare(TheDb, KSql3);
sl@0
   231
	TEST2(rc, KErrNone);
sl@0
   232
	rc = stmt.BindInt(0, 1);
sl@0
   233
	TEST2(rc, KErrNone);
sl@0
   234
	rc = stmt.BindInt(1, 2);
sl@0
   235
	TEST2(rc, KErrNone);
sl@0
   236
	rc = stmt.BindInt(2, 3);
sl@0
   237
	TEST2(rc, KErrNone);
sl@0
   238
	rc = stmt.Exec();
sl@0
   239
	TEST2(rc, 1);
sl@0
   240
	stmt.Close();
sl@0
   241
sl@0
   242
	TUint32 fc2 = User::FastCounter();
sl@0
   243
	TheMdeTablesCreationTime += TimeDiffUs(fc1, fc2);
sl@0
   244
	}
sl@0
   245
sl@0
   246
TInt64 LastInsertedRowId()
sl@0
   247
	{
sl@0
   248
	_LIT(KSql, "SELECT last_insert_rowid();");
sl@0
   249
	TUint32 fc1 = User::FastCounter();
sl@0
   250
	RSqlStatement stmt;
sl@0
   251
	TInt err = stmt.Prepare(TheDb, KSql);
sl@0
   252
	TEST2(err, KErrNone);
sl@0
   253
	err = stmt.Next();
sl@0
   254
	TEST2(err, KSqlAtRow);
sl@0
   255
	TInt64 rowid = stmt.ColumnInt64(0); 
sl@0
   256
	stmt.Close();
sl@0
   257
	TUint32 fc2 = User::FastCounter();
sl@0
   258
	TheLastInsertedRowIdTime += TimeDiffUs(fc1, fc2);
sl@0
   259
	return rowid;
sl@0
   260
	}
sl@0
   261
sl@0
   262
void DoCreateTables1()
sl@0
   263
	{
sl@0
   264
	_LIT(KSql1, "CREATE TABLE IF NOT EXISTS NamespaceDef(NamespaceDefId INTEGER PRIMARY KEY,ReadOnly INTEGER,VendorId INTEGER,Name TEXT)");
sl@0
   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)");
sl@0
   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)");
sl@0
   267
	_LIT(KSql4, "CREATE TABLE IF NOT EXISTS RelationDef(RelationDefId INTEGER PRIMARY KEY,NamespaceDefId INTEGER NOT NULL,Name TEXT)");
sl@0
   268
	_LIT(KSql5, "CREATE TABLE IF NOT EXISTS EventDef(EventDefId INTEGER PRIMARY KEY,NamespaceDefId INTEGER NOT NULL,Priority INTEGER,Name TEXT)");
sl@0
   269
sl@0
   270
	TUint32 fc1 = User::FastCounter();
sl@0
   271
	
sl@0
   272
	TInt rc = TheDb.Exec(KSql1);
sl@0
   273
	TEST(rc >= 0);
sl@0
   274
	rc = TheDb.Exec(KSql2);
sl@0
   275
	TEST(rc >= 0);
sl@0
   276
	rc = TheDb.Exec(KSql3);
sl@0
   277
	TEST(rc >= 0);
sl@0
   278
	rc = TheDb.Exec(KSql4);
sl@0
   279
	TEST(rc >= 0);
sl@0
   280
	rc = TheDb.Exec(KSql5);
sl@0
   281
	TEST(rc >= 0);
sl@0
   282
	
sl@0
   283
	_LIT(KSql6, "INSERT INTO NamespaceDef(ReadOnly,VendorId,Name) Values(?,?,?);");
sl@0
   284
	RSqlStatement stmt;
sl@0
   285
	rc = stmt.Prepare(TheDb, KSql6);
sl@0
   286
	TEST2(rc, KErrNone);
sl@0
   287
	rc = stmt.BindInt(0, 1);
sl@0
   288
	TEST2(rc, KErrNone);
sl@0
   289
	rc = stmt.BindInt(1, 2);
sl@0
   290
	TEST2(rc, KErrNone);
sl@0
   291
	rc = stmt.BindText(2, _L("Nokia"));
sl@0
   292
	TEST2(rc, KErrNone);
sl@0
   293
	rc = stmt.Exec();
sl@0
   294
	TEST2(rc, 1);
sl@0
   295
	stmt.Close();
sl@0
   296
sl@0
   297
	TUint32 fc2 = User::FastCounter();
sl@0
   298
	TheCreateTables1Time += TimeDiffUs(fc1, fc2);
sl@0
   299
	}
sl@0
   300
sl@0
   301
void BeginTransaction()
sl@0
   302
	{
sl@0
   303
	TInt err = TheDb.Exec(_L("BEGIN"));
sl@0
   304
	TEST(err >= 0);
sl@0
   305
	}
sl@0
   306
sl@0
   307
void CommitTransaction()
sl@0
   308
	{
sl@0
   309
	TInt err = TheDb.Exec(_L("COMMIT"));
sl@0
   310
	TEST(err >= 0);
sl@0
   311
	}
sl@0
   312
sl@0
   313
void DoCreateTables2()
sl@0
   314
	{
sl@0
   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))");
sl@0
   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)");
sl@0
   317
	_LIT(KSql3, "CREATE TRIGGER DeleteRelations1 BEFORE DELETE ON Object1 BEGIN DELETE FROM Relations1 WHERE LeftObjectId=OLD.ObjectId OR RightObjectId=OLD.ObjectId; END");
sl@0
   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)");
sl@0
   319
	_LIT(KSql5, "CREATE TRIGGER DeleteEvent1 BEFORE DELETE ON Object1 BEGIN DELETE FROM Event1 WHERE ObjectId=OLD.ObjectId; END");
sl@0
   320
	_LIT(KSql6, "CREATE TABLE IF NOT EXISTS TextSearch1(WordId INTEGER NOT NULL,ObjectId INTEGER NOT NULL,Position INTEGER)");
sl@0
   321
	_LIT(KSql7, "CREATE TRIGGER DeleteTextSearch1 BEFORE DELETE ON Object1 BEGIN DELETE FROM TextSearch1 WHERE ObjectId=OLD.ObjectId; END");
sl@0
   322
	_LIT(KSql8, "CREATE INDEX FreetextWordIdIndex1 ON TextSearch1(WordId)");
sl@0
   323
	_LIT(KSql9, "CREATE INDEX FreetextObjectIdIndex1 ON TextSearch1(ObjectId)");
sl@0
   324
	_LIT(KSql10, "CREATE TABLE IF NOT EXISTS TextSearchDictionary1(WordId INTEGER PRIMARY KEY,Word TEXT NOT NULL)");
sl@0
   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");
sl@0
   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");
sl@0
   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");
sl@0
   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");
sl@0
   329
	_LIT(KSql15, "CREATE INDEX RelationsLeftObjectIdIndex1 ON Relations1(LeftObjectId)");
sl@0
   330
	_LIT(KSql16, "CREATE INDEX RelationsRightObjectIdIndex1 ON Relations1(RightObjectId)");
sl@0
   331
	_LIT(KSql17, "CREATE INDEX ObjectDefIndex1 ON Object1(ObjectDefId)");
sl@0
   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))");
sl@0
   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))");
sl@0
   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))");
sl@0
   335
	_LIT(KSql21, "CREATE TABLE IF NOT EXISTS Message1(ObjectId INTEGER NOT NULL,Received INTEGER,ToWhom TEXT,Sender TEXT, UNIQUE(ObjectId))");
sl@0
   336
	_LIT(KSql22, "CREATE TABLE IF NOT EXISTS Album1(ObjectId INTEGER NOT NULL,Ordered INTEGER,Type INTEGER, UNIQUE(ObjectId))");
sl@0
   337
	_LIT(KSql23, "CREATE TABLE IF NOT EXISTS Tag1(ObjectId INTEGER NOT NULL, UNIQUE(ObjectId))");
sl@0
   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))");
sl@0
   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))");
sl@0
   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))");
sl@0
   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))");
sl@0
   342
	_LIT(KSql28, "CREATE TABLE IF NOT EXISTS TrackLog1(ObjectId INTEGER NOT NULL,Length LARGEINT,StartTime LARGEINT,StopTime LARGEINT, UNIQUE(ObjectId))");
sl@0
   343
	
sl@0
   344
	const TPtrC KSql[] = 
sl@0
   345
		{
sl@0
   346
		KSql1(), KSql2(), KSql3(), KSql4(), KSql5(), KSql6(), KSql7(), KSql8(), KSql9(), KSql10(), 
sl@0
   347
		KSql11(), KSql12(), KSql13(), KSql14(), KSql15(), KSql16(), KSql17(), KSql18(), KSql19(), KSql20(), 
sl@0
   348
		KSql21(), KSql22(), KSql23(), KSql24(), KSql25(), KSql26(), KSql27(), KSql28() 
sl@0
   349
		};
sl@0
   350
	
sl@0
   351
	TUint32 fc1 = User::FastCounter();	
sl@0
   352
	for(TInt i=0;i<(sizeof(KSql)/sizeof(KSql[0]));++i)
sl@0
   353
		{
sl@0
   354
		TInt err = TheDb.Exec(KSql[i]);
sl@0
   355
		TEST(err >= 0);
sl@0
   356
		}
sl@0
   357
	TUint32 fc2 = User::FastCounter();
sl@0
   358
	TheCreateTables2Time += TimeDiffUs(fc1, fc2);
sl@0
   359
	}
sl@0
   360
sl@0
   361
void DoCreateTables3()
sl@0
   362
	{
sl@0
   363
	const TInt KInsObjDefRecCnt = 12;
sl@0
   364
	const TInt KInsPropDefRecCnt[KInsObjDefRecCnt] = {7, 11, 6, 7, 3, 2, 0, 24, 6, 40, 6, 3};
sl@0
   365
	TUint32 fc1 = User::FastCounter();	
sl@0
   366
	for(TInt i=0;i<KInsObjDefRecCnt;++i)
sl@0
   367
		{
sl@0
   368
		TBuf<10> objDefName;
sl@0
   369
		RSqlStatement stmt1;
sl@0
   370
		TInt err = stmt1.Prepare(TheDb, _L("INSERT INTO ObjectDef(NamespaceDefId, ParentDefId, Flags, Name) Values(?,?,?,?)"));
sl@0
   371
		TEST2(err, KErrNone);
sl@0
   372
		err = stmt1.BindInt(0, 1);
sl@0
   373
		TEST2(err, KErrNone);
sl@0
   374
		err = stmt1.BindInt(1, 2);
sl@0
   375
		TEST2(err, KErrNone);
sl@0
   376
		err = stmt1.BindInt(2, 3);
sl@0
   377
		TEST2(err, KErrNone);
sl@0
   378
		objDefName.Copy(_L("ObjDef"));
sl@0
   379
		objDefName.AppendNum(i + 1);
sl@0
   380
		err = stmt1.BindText(3, objDefName);
sl@0
   381
		TEST2(err, KErrNone);
sl@0
   382
		err = stmt1.Exec();
sl@0
   383
		TEST2(err, 1);
sl@0
   384
		stmt1.Close();
sl@0
   385
		TInt64 objdefid = LastInsertedRowId();
sl@0
   386
		for(TInt j=0;j<KInsPropDefRecCnt[i];++j)
sl@0
   387
			{
sl@0
   388
			TBuf<10> propDefName;
sl@0
   389
			RSqlStatement stmt2;
sl@0
   390
			err = stmt2.Prepare(TheDb, _L("INSERT INTO PropertyDef(ObjectDefId,Flags,Type,MinValue,MaxValue,Name) Values(?,?,?,?,?,?);"));
sl@0
   391
			TEST2(err, KErrNone);
sl@0
   392
			err = stmt2.BindInt64(0, objdefid);
sl@0
   393
			TEST2(err, KErrNone);
sl@0
   394
			err = stmt2.BindInt(1, 2);
sl@0
   395
			TEST2(err, KErrNone);
sl@0
   396
			err = stmt2.BindInt(2, 3);
sl@0
   397
			TEST2(err, KErrNone);
sl@0
   398
			err = stmt2.BindInt(3, 100);
sl@0
   399
			TEST2(err, KErrNone);
sl@0
   400
			err = stmt2.BindInt(4, 200);
sl@0
   401
			TEST2(err, KErrNone);
sl@0
   402
			propDefName.Copy(_L("PropDef"));
sl@0
   403
			propDefName.AppendNum(j + 1);
sl@0
   404
			err = stmt2.BindText(5, propDefName);
sl@0
   405
			TEST2(err, KErrNone);
sl@0
   406
			err = stmt2.Exec();
sl@0
   407
			TEST2(err, 1);
sl@0
   408
			stmt2.Close();
sl@0
   409
			LastInsertedRowId();
sl@0
   410
			}
sl@0
   411
		}
sl@0
   412
	TUint32 fc2 = User::FastCounter();
sl@0
   413
	TheCreateTables3Time += TimeDiffUs(fc1, fc2);
sl@0
   414
	}
sl@0
   415
sl@0
   416
void DoCreateTriggers()
sl@0
   417
	{
sl@0
   418
	_LIT(KSql1, "CREATE TRIGGER DeleteLocation1 DELETE ON Object1 BEGIN DELETE FROM Location1 WHERE ObjectId=OLD.ObjectId; END");
sl@0
   419
	_LIT(KSql2, "CREATE TRIGGER DeleteCalendar1 DELETE ON Object1 BEGIN DELETE FROM Calendar1 WHERE ObjectId=OLD.ObjectId; END");
sl@0
   420
	_LIT(KSql3, "CREATE TRIGGER DeleteContact1 DELETE ON Object1 BEGIN DELETE FROM Contact1 WHERE ObjectId=OLD.ObjectId; END");
sl@0
   421
	_LIT(KSql4, "CREATE TRIGGER DeleteMessage1 DELETE ON Object1 BEGIN DELETE FROM Message1 WHERE ObjectId=OLD.ObjectId; END");
sl@0
   422
	_LIT(KSql5, "CREATE TRIGGER DeleteAlbum1 DELETE ON Object1 BEGIN DELETE FROM Album1 WHERE ObjectId=OLD.ObjectId; END");
sl@0
   423
	_LIT(KSql6, "CREATE TRIGGER DeleteTag1 DELETE ON Object1 BEGIN DELETE FROM Tag1 WHERE ObjectId=OLD.ObjectId; END");
sl@0
   424
	_LIT(KSql7, "CREATE TRIGGER DeleteMediaObject1 DELETE ON Object1 BEGIN DELETE FROM MediaObject1 WHERE ObjectId=OLD.ObjectId; END");
sl@0
   425
	_LIT(KSql8, "CREATE TRIGGER DeleteVideo1 DELETE ON Object1 BEGIN DELETE FROM Video1 WHERE ObjectId=OLD.ObjectId; END");
sl@0
   426
	_LIT(KSql9, "CREATE TRIGGER DeleteImage1 DELETE ON Object1 BEGIN DELETE FROM Image1 WHERE ObjectId=OLD.ObjectId; END");
sl@0
   427
	_LIT(KSql10, "CREATE TRIGGER DeleteAudio1 DELETE ON Object1 BEGIN DELETE FROM Audio1 WHERE ObjectId=OLD.ObjectId; END");
sl@0
   428
	_LIT(KSql11, "CREATE TRIGGER DeleteTrackLog1 DELETE ON Object1 BEGIN DELETE FROM TrackLog1 WHERE ObjectId=OLD.ObjectId; END");
sl@0
   429
	
sl@0
   430
	const TPtrC KSql[] = 
sl@0
   431
		{
sl@0
   432
		KSql1(), KSql2(), KSql3(), KSql4(), KSql5(), KSql6(), KSql7(), KSql8(), KSql9(), KSql10(), KSql11() 
sl@0
   433
		};
sl@0
   434
	
sl@0
   435
	TUint32 fc1 = User::FastCounter();	
sl@0
   436
	for(TInt i=0;i<(sizeof(KSql)/sizeof(KSql[0]));++i)
sl@0
   437
		{
sl@0
   438
		TInt err = TheDb.Exec(KSql[i]);
sl@0
   439
		TEST(err >= 0);
sl@0
   440
		}
sl@0
   441
	TUint32 fc2 = User::FastCounter();
sl@0
   442
	TheCreateTriggersTime += TimeDiffUs(fc1, fc2);
sl@0
   443
	}
sl@0
   444
sl@0
   445
void DoInsertEventRelationDefs()
sl@0
   446
	{
sl@0
   447
	_LIT(KSql1, "INSERT INTO EventDef (NamespaceDefId, Priority, Name ) Values(?, ?, ?);");
sl@0
   448
	const TInt KSql1Cnt = 7;
sl@0
   449
	_LIT(KSql2, "INSERT INTO RelationDef (NamespaceDefId,Name) Values(?,?);");
sl@0
   450
	const TInt KSql2Cnt = 8;
sl@0
   451
	
sl@0
   452
	TUint32 fc1 = User::FastCounter();	
sl@0
   453
	
sl@0
   454
	for(TInt i=0;i<KSql1Cnt;++i)
sl@0
   455
		{
sl@0
   456
		TBuf<10> eventDefName;
sl@0
   457
		RSqlStatement stmt;
sl@0
   458
		TInt err = stmt.Prepare(TheDb, KSql1);
sl@0
   459
		TEST2(err, KErrNone);
sl@0
   460
		err = stmt.BindInt(0, 1);
sl@0
   461
		TEST2(err, KErrNone);
sl@0
   462
		err = stmt.BindInt(1, 2);
sl@0
   463
		TEST2(err, KErrNone);
sl@0
   464
		eventDefName.Copy(_L("EvtDef"));
sl@0
   465
		eventDefName.AppendNum(i + 1);
sl@0
   466
		err = stmt.BindText(2, eventDefName);
sl@0
   467
		TEST2(err, KErrNone);
sl@0
   468
		err = stmt.Exec();
sl@0
   469
		TEST2(err, 1);
sl@0
   470
		stmt.Close();
sl@0
   471
		LastInsertedRowId();
sl@0
   472
		}
sl@0
   473
sl@0
   474
	for(TInt i=0;i<KSql2Cnt;++i)
sl@0
   475
		{
sl@0
   476
		TBuf<10> relDefName;
sl@0
   477
		RSqlStatement stmt;
sl@0
   478
		TInt err = stmt.Prepare(TheDb, KSql2);
sl@0
   479
		TEST2(err, KErrNone);
sl@0
   480
		err = stmt.BindInt(0, 1);
sl@0
   481
		TEST2(err, KErrNone);
sl@0
   482
		relDefName.Copy(_L("RelDef"));
sl@0
   483
		relDefName.AppendNum(i + 1);
sl@0
   484
		err = stmt.BindText(1, relDefName);
sl@0
   485
		TEST2(err, KErrNone);
sl@0
   486
		err = stmt.Exec();
sl@0
   487
		TEST2(err, 1);
sl@0
   488
		stmt.Close();
sl@0
   489
		LastInsertedRowId();
sl@0
   490
		}
sl@0
   491
	
sl@0
   492
	TUint32 fc2 = User::FastCounter();
sl@0
   493
	TheInsertEventRelationTime += TimeDiffUs(fc1, fc2);
sl@0
   494
	}
sl@0
   495
sl@0
   496
void DoDeleteObjPropertyDef()
sl@0
   497
	{
sl@0
   498
	_LIT(KSql1, "DELETE FROM ObjectDef WHERE ObjectDefId=?;");
sl@0
   499
	_LIT(KSql2, "DELETE FROM PropertyDef WHERE ObjectDefId=?;");
sl@0
   500
sl@0
   501
	TUint32 fc1 = User::FastCounter();
sl@0
   502
	
sl@0
   503
	RSqlStatement stmt1;
sl@0
   504
	TInt err = stmt1.Prepare(TheDb, KSql1);
sl@0
   505
	TEST2(err, KErrNone);
sl@0
   506
	err = stmt1.BindInt(0, 0);
sl@0
   507
	TEST2(err, KErrNone);
sl@0
   508
	err = stmt1.Exec();
sl@0
   509
	TEST(err >= 0);
sl@0
   510
	stmt1.Close();
sl@0
   511
	
sl@0
   512
	RSqlStatement stmt2;
sl@0
   513
	err = stmt2.Prepare(TheDb, KSql2);
sl@0
   514
	TEST2(err, KErrNone);
sl@0
   515
	err = stmt2.BindInt(0, 0);
sl@0
   516
	TEST2(err, KErrNone);
sl@0
   517
	err = stmt2.Exec();
sl@0
   518
	TEST(err >= 0);
sl@0
   519
	stmt2.Close();
sl@0
   520
	
sl@0
   521
	TUint32 fc2 = User::FastCounter();
sl@0
   522
	TheDeleteObjPropertyTime += TimeDiffUs(fc1, fc2);
sl@0
   523
	}
sl@0
   524
sl@0
   525
void DoInsertCol2Prop()
sl@0
   526
	{
sl@0
   527
	_LIT(KSql1, "CREATE TABLE IF NOT EXISTS Col2Prop(ObjectDefId INTEGER NOT NULL,PropertyDefId INTEGER NOT NULL,ColumnId INTEGER NOT NULL)");
sl@0
   528
	TInt KCol2PropCnt = KItemCnt;
sl@0
   529
	_LIT(KSql2, "INSERT INTO Col2Prop(ObjectDefId,PropertyDefId,ColumnId) Values(?,?,?);");
sl@0
   530
	
sl@0
   531
	TUint32 fc1 = User::FastCounter();
sl@0
   532
sl@0
   533
	TInt err = TheDb.Exec(KSql1);
sl@0
   534
	TEST(err >= 0);
sl@0
   535
	for(TInt i=0;i<KCol2PropCnt;++i)
sl@0
   536
		{
sl@0
   537
		RSqlStatement stmt;
sl@0
   538
		err = stmt.Prepare(TheDb, KSql2);
sl@0
   539
		TEST2(err, KErrNone);
sl@0
   540
		err = stmt.BindInt(0, 10);
sl@0
   541
		TEST2(err, KErrNone);
sl@0
   542
		err = stmt.BindInt(1, 20);
sl@0
   543
		TEST2(err, KErrNone);
sl@0
   544
		err = stmt.BindInt(2, i);
sl@0
   545
		TEST2(err, KErrNone);
sl@0
   546
		err = stmt.Exec();
sl@0
   547
		TEST(err >= 0);
sl@0
   548
		stmt.Close();
sl@0
   549
		}
sl@0
   550
	
sl@0
   551
	TUint32 fc2 = User::FastCounter();
sl@0
   552
	TheInsertCol2PropTime += TimeDiffUs(fc1, fc2);
sl@0
   553
	}
sl@0
   554
sl@0
   555
/**
sl@0
   556
@SYMTestCaseID			PDS-SQL-UT-4149
sl@0
   557
@SYMTestCaseDesc		MDE database creation performance test.
sl@0
   558
						The test creates the MDE database using the SQL statements from the 
sl@0
   559
						production code of the MetaDataEngine server. The time taken for the execution of
sl@0
   560
						SQL statements is measured and printed out.
sl@0
   561
@SYMTestActions			MDE database creation performance test.
sl@0
   562
@SYMTestExpectedResults Test must not fail
sl@0
   563
@SYMTestPriority		High
sl@0
   564
@SYMDEF					DEF142327
sl@0
   565
*/
sl@0
   566
void CreateDb()
sl@0
   567
	{
sl@0
   568
	DoCreateDbFile();
sl@0
   569
	TheDb.Close();
sl@0
   570
	DoCreateDbFile();
sl@0
   571
	
sl@0
   572
	TUint32 fc1 = User::FastCounter();	
sl@0
   573
	
sl@0
   574
	////////////////////////////////
sl@0
   575
	DoGetlastItemId();
sl@0
   576
	MdePreferencesCheck();
sl@0
   577
	CreateMdeTables();
sl@0
   578
	////////////////////////////////
sl@0
   579
	TUint32 fc2 = User::FastCounter();	
sl@0
   580
	BeginTransaction();
sl@0
   581
	//
sl@0
   582
	DoCreateTables1();
sl@0
   583
	DoCreateTables2();
sl@0
   584
	DoCreateTables3();
sl@0
   585
	DoCreateTriggers();
sl@0
   586
	DoInsertEventRelationDefs();
sl@0
   587
	DoDeleteObjPropertyDef();
sl@0
   588
	DoInsertCol2Prop();
sl@0
   589
	//
sl@0
   590
	CommitTransaction();
sl@0
   591
	TUint32 fc3 = User::FastCounter();
sl@0
   592
	TheTransactionTime += TimeDiffUs(fc2, fc3);
sl@0
   593
	TheDbCreateTime += TimeDiffUs(fc1, fc3);
sl@0
   594
	}
sl@0
   595
sl@0
   596
void DoHarvestSelect()
sl@0
   597
	{
sl@0
   598
	TUint32 fc1 = User::FastCounter();	
sl@0
   599
	for(TInt i=0;i<TheIterationsCount;++i)
sl@0
   600
		{
sl@0
   601
		BeginTransaction();
sl@0
   602
		for(TInt j=0;j<TheIterations[i];++j)
sl@0
   603
			{
sl@0
   604
			_LIT(KSql, "SELECT ObjectId, Flags, LastModifiedDate, Size FROM Object1 WHERE NOT Flags&? AND (Flags&? OR Flags&?) AND MediaId=? AND URI=?;");
sl@0
   605
			RSqlStatement stmt;
sl@0
   606
			TInt err = stmt.Prepare(TheDb, KSql);
sl@0
   607
			TEST2(err, KErrNone);
sl@0
   608
			err = stmt.BindInt(0, 8);
sl@0
   609
			TEST2(err, KErrNone);
sl@0
   610
			err = stmt.BindInt(1, 16);
sl@0
   611
			TEST2(err, KErrNone);
sl@0
   612
			err = stmt.BindInt(2, 32);
sl@0
   613
			TEST2(err, KErrNone);
sl@0
   614
			TBuf<16> media;
sl@0
   615
			media.Copy(_L("media"));
sl@0
   616
			media.AppendNum(j + 1);
sl@0
   617
			err = stmt.BindText(3, media);
sl@0
   618
			TEST2(err, KErrNone);
sl@0
   619
			TBuf<16> uri;
sl@0
   620
			uri.Copy(_L("uri"));
sl@0
   621
			uri.AppendNum(j + 1);
sl@0
   622
			err = stmt.BindText(4, uri);
sl@0
   623
			TEST2(err, KErrNone);
sl@0
   624
			while((err = stmt.Next()) == KSqlAtRow)
sl@0
   625
				{
sl@0
   626
				}
sl@0
   627
			TEST2(err, KSqlAtEnd);
sl@0
   628
			stmt.Close();
sl@0
   629
			}
sl@0
   630
		CommitTransaction();
sl@0
   631
		}
sl@0
   632
	TUint32 fc2 = User::FastCounter();
sl@0
   633
	TheHarvestSelectTime += TimeDiffUs(fc1, fc2);
sl@0
   634
	}
sl@0
   635
sl@0
   636
void DoHarvestInsertObjImage()
sl@0
   637
	{
sl@0
   638
	_LIT(KSql1, "INSERT INTO Object1(ObjectId,ObjectDefId,Flags,MediaId,GuidHigh,GuidLow,URI,Origin,Size,CreationDate,LastModifiedDate) VALUES(?,?,?,?,?,?,?,?,?,?,?);");
sl@0
   639
	_LIT(KSql2, "INSERT INTO Image1(ObjectId) VALUES(?);");
sl@0
   640
	
sl@0
   641
	TUint32 fc1 = User::FastCounter();	
sl@0
   642
	TInt objdef = 0;
sl@0
   643
	for(TInt i=0;i<TheIterationsCount;++i)
sl@0
   644
		{
sl@0
   645
		BeginTransaction();
sl@0
   646
		for(TInt j=0;j<TheIterations[i];++j)
sl@0
   647
			{
sl@0
   648
			++objdef;
sl@0
   649
			RSqlStatement stmt1;
sl@0
   650
			TInt err = stmt1.Prepare(TheDb, KSql1);
sl@0
   651
			TEST2(err, KErrNone);
sl@0
   652
			err = stmt1.BindInt(0, objdef);
sl@0
   653
			TEST2(err, KErrNone);
sl@0
   654
			err = stmt1.BindInt(1, 9);
sl@0
   655
			TEST2(err, KErrNone);
sl@0
   656
			err = stmt1.BindInt(2, 48);
sl@0
   657
			TEST2(err, KErrNone);
sl@0
   658
			err = stmt1.BindInt(3, 3);
sl@0
   659
			TEST2(err, KErrNone);
sl@0
   660
			err = stmt1.BindInt(4, j + 1 + i * 100);
sl@0
   661
			TEST2(err, KErrNone);
sl@0
   662
			err = stmt1.BindInt(5, j + 1 + i * 10000);
sl@0
   663
			TEST2(err, KErrNone);
sl@0
   664
			TBuf<16> uri;
sl@0
   665
			uri.Copy(_L("URI-"));
sl@0
   666
			uri.AppendNum(j + 1 + i * 100);
sl@0
   667
			err = stmt1.BindText(6, uri);
sl@0
   668
			TEST2(err, KErrNone);
sl@0
   669
			err = stmt1.BindInt(7, 0);
sl@0
   670
			TEST2(err, KErrNone);
sl@0
   671
			err = stmt1.BindInt(8, 1000000);
sl@0
   672
			TEST2(err, KErrNone);
sl@0
   673
			err = stmt1.BindInt64(9, 32324234218723LL);
sl@0
   674
			TEST2(err, KErrNone);
sl@0
   675
			err = stmt1.BindInt64(10, 5675069785676565LL);
sl@0
   676
			TEST2(err, KErrNone);
sl@0
   677
			err = stmt1.Exec();
sl@0
   678
			TEST(err >= 0);
sl@0
   679
			stmt1.Close();
sl@0
   680
sl@0
   681
			RSqlStatement stmt2;
sl@0
   682
			err = stmt2.Prepare(TheDb, KSql2);
sl@0
   683
			TEST2(err, KErrNone);
sl@0
   684
			err = stmt2.BindInt(0, objdef);
sl@0
   685
			TEST2(err, KErrNone);
sl@0
   686
			err = stmt2.Exec();
sl@0
   687
			TEST(err >= 0);
sl@0
   688
			stmt2.Close();
sl@0
   689
			}
sl@0
   690
		CommitTransaction();
sl@0
   691
		}
sl@0
   692
	TUint32 fc2 = User::FastCounter();
sl@0
   693
	TheHarvestInsertObjImageTime += TimeDiffUs(fc1, fc2);
sl@0
   694
	}
sl@0
   695
sl@0
   696
void DoHarvestSelect2()
sl@0
   697
	{
sl@0
   698
	TUint32 fc1 = User::FastCounter();
sl@0
   699
	///////////////////////////////////////////////////////////////////////
sl@0
   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 ;");
sl@0
   701
	RSqlStatement stmt1;
sl@0
   702
	TInt err = stmt1.Prepare(TheDb, KSql1);
sl@0
   703
	TEST2(err, KErrNone);
sl@0
   704
	err = stmt1.BindInt(0, 8);
sl@0
   705
	TEST2(err, KErrNone);
sl@0
   706
	err = stmt1.BindInt(1, 16);
sl@0
   707
	TEST2(err, KErrNone);
sl@0
   708
	err = stmt1.BindInt(2, 32);
sl@0
   709
	TEST2(err, KErrNone);
sl@0
   710
	err = stmt1.BindInt(3, 64);
sl@0
   711
	TEST2(err, KErrNone);
sl@0
   712
	err = stmt1.BindInt(4, 128);
sl@0
   713
	TEST2(err, KErrNone);
sl@0
   714
	err = stmt1.BindInt(5, 1);
sl@0
   715
	TEST2(err, KErrNone);
sl@0
   716
	err = stmt1.BindInt(6, 8);
sl@0
   717
	TEST2(err, KErrNone);
sl@0
   718
	err = stmt1.BindInt(7, 16);
sl@0
   719
	TEST2(err, KErrNone);
sl@0
   720
	err = stmt1.BindInt(8, 32);
sl@0
   721
	TEST2(err, KErrNone);
sl@0
   722
	err = stmt1.BindInt(9, 1);
sl@0
   723
	TEST2(err, KErrNone);
sl@0
   724
	err = stmt1.BindInt(10, 1);
sl@0
   725
	TEST2(err, KErrNone);
sl@0
   726
	while((err = stmt1.Next()) == KSqlAtRow)
sl@0
   727
		{
sl@0
   728
		}
sl@0
   729
	TEST2(err, KSqlAtEnd);
sl@0
   730
	stmt1.Close();
sl@0
   731
	///////////////////////////////////////////////////////////////////////
sl@0
   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 ;");
sl@0
   733
	RSqlStatement stmt2;
sl@0
   734
	err = stmt2.Prepare(TheDb, KSql2);
sl@0
   735
	TEST2(err, KErrNone);
sl@0
   736
	err = stmt2.BindInt(0, 8);
sl@0
   737
	TEST2(err, KErrNone);
sl@0
   738
	err = stmt2.BindInt(1, 16);
sl@0
   739
	TEST2(err, KErrNone);
sl@0
   740
	err = stmt2.BindInt(2, 1);
sl@0
   741
	TEST2(err, KErrNone);
sl@0
   742
	while((err = stmt2.Next()) == KSqlAtRow)
sl@0
   743
		{
sl@0
   744
		}
sl@0
   745
	TEST2(err, KSqlAtEnd);
sl@0
   746
	stmt2.Close();
sl@0
   747
	///////////////////////////////////////////////////////////////////////
sl@0
   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 ;");
sl@0
   749
	RSqlStatement stmt3;
sl@0
   750
	err = stmt3.Prepare(TheDb, KSql3);
sl@0
   751
	TEST2(err, KErrNone);
sl@0
   752
	err = stmt3.BindInt(0, 8);
sl@0
   753
	TEST2(err, KErrNone);
sl@0
   754
	err = stmt3.BindInt(1, 16);
sl@0
   755
	TEST2(err, KErrNone);
sl@0
   756
	err = stmt3.BindInt(2, 1);
sl@0
   757
	TEST2(err, KErrNone);
sl@0
   758
	while((err = stmt3.Next()) == KSqlAtRow)
sl@0
   759
		{
sl@0
   760
		}
sl@0
   761
	TEST2(err, KSqlAtEnd);
sl@0
   762
	stmt3.Close();
sl@0
   763
	/////////////////////////////////////////////////////////////////////////
sl@0
   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 ;");
sl@0
   765
	RSqlStatement stmt4;
sl@0
   766
	err = stmt4.Prepare(TheDb, KSql4);
sl@0
   767
	TEST2(err, KErrNone);
sl@0
   768
	err = stmt4.BindInt(0, 8);
sl@0
   769
	TEST2(err, KErrNone);
sl@0
   770
	err = stmt4.BindInt(1, 16);
sl@0
   771
	TEST2(err, KErrNone);
sl@0
   772
	while((err = stmt4.Next()) == KSqlAtRow)
sl@0
   773
		{
sl@0
   774
		}
sl@0
   775
	TEST2(err, KSqlAtEnd);
sl@0
   776
	stmt4.Close();
sl@0
   777
	///////////////////////////////////////////////////////////////////////////
sl@0
   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 ;");
sl@0
   779
	RSqlStatement stmt5;
sl@0
   780
	err = stmt5.Prepare(TheDb, KSql5);
sl@0
   781
	TEST2(err, KErrNone);
sl@0
   782
	err = stmt5.BindInt(0, 8);
sl@0
   783
	TEST2(err, KErrNone);
sl@0
   784
	err = stmt5.BindInt(1, 16);
sl@0
   785
	TEST2(err, KErrNone);
sl@0
   786
	err = stmt5.BindInt(2, 32);
sl@0
   787
	TEST2(err, KErrNone);
sl@0
   788
	err = stmt5.BindInt(3, 64);
sl@0
   789
	TEST2(err, KErrNone);
sl@0
   790
	err = stmt5.BindInt(4, 128);
sl@0
   791
	TEST2(err, KErrNone);
sl@0
   792
	err = stmt5.BindInt(5, 1);
sl@0
   793
	TEST2(err, KErrNone);
sl@0
   794
	err = stmt5.BindInt(6, 8);
sl@0
   795
	TEST2(err, KErrNone);
sl@0
   796
	err = stmt5.BindInt(7, 16);
sl@0
   797
	TEST2(err, KErrNone);
sl@0
   798
	err = stmt5.BindInt(8, 32);
sl@0
   799
	TEST2(err, KErrNone);
sl@0
   800
	err = stmt5.BindInt(9, 1);
sl@0
   801
	TEST2(err, KErrNone);
sl@0
   802
	err = stmt5.BindInt(10, 1);
sl@0
   803
	TEST2(err, KErrNone);
sl@0
   804
	while((err = stmt5.Next()) == KSqlAtRow)
sl@0
   805
		{
sl@0
   806
		}
sl@0
   807
	TEST2(err, KSqlAtEnd);
sl@0
   808
	stmt5.Close();
sl@0
   809
	////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   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 ;");	
sl@0
   811
	RSqlStatement stmt6;
sl@0
   812
	err = stmt6.Prepare(TheDb, KSql6);
sl@0
   813
	TEST2(err, KErrNone);
sl@0
   814
	err = stmt6.BindInt(0, 8);
sl@0
   815
	TEST2(err, KErrNone);
sl@0
   816
	err = stmt6.BindInt(1, 16);
sl@0
   817
	TEST2(err, KErrNone);
sl@0
   818
	err = stmt6.BindInt(2, 32);
sl@0
   819
	TEST2(err, KErrNone);
sl@0
   820
	err = stmt6.BindInt(3, 64);
sl@0
   821
	TEST2(err, KErrNone);
sl@0
   822
	err = stmt6.BindInt(4, 128);
sl@0
   823
	TEST2(err, KErrNone);
sl@0
   824
	err = stmt6.BindInt(5, 1);
sl@0
   825
	TEST2(err, KErrNone);
sl@0
   826
	while((err = stmt6.Next()) == KSqlAtRow)
sl@0
   827
		{
sl@0
   828
		}
sl@0
   829
	TEST2(err, KSqlAtEnd);
sl@0
   830
	stmt6.Close();
sl@0
   831
	
sl@0
   832
	TUint32 fc2 = User::FastCounter();
sl@0
   833
	TheHarvestSelect2Time += TimeDiffUs(fc1, fc2);
sl@0
   834
	}
sl@0
   835
sl@0
   836
void DoHarvestInsertEvent()
sl@0
   837
	{
sl@0
   838
	TUint32 fc1 = User::FastCounter();
sl@0
   839
	
sl@0
   840
	_LIT(KSql, "INSERT INTO Event1(EventId,ObjectId,EventDefId,Timestamp,Source,Participant) VALUES(?,?,?,?,?,?);");
sl@0
   841
	const TInt KEventCnt = KItemCnt;
sl@0
   842
	
sl@0
   843
	for(TInt i=0;i<KEventCnt;++i)
sl@0
   844
		{
sl@0
   845
		BeginTransaction();
sl@0
   846
		RSqlStatement stmt;
sl@0
   847
		TInt err = stmt.Prepare(TheDb, KSql);
sl@0
   848
		TEST2(err, KErrNone);
sl@0
   849
		err = stmt.BindInt(0, i + 1);
sl@0
   850
		TEST2(err, KErrNone);
sl@0
   851
		err = stmt.BindInt(1, i + 1);
sl@0
   852
		TEST2(err, KErrNone);
sl@0
   853
		err = stmt.BindInt(2, i + 1);
sl@0
   854
		TEST2(err, KErrNone);
sl@0
   855
		err = stmt.BindInt64(3, 329231202230LL);
sl@0
   856
		TEST2(err, KErrNone);
sl@0
   857
		err = stmt.BindInt(4, 1);
sl@0
   858
		TEST2(err, KErrNone);
sl@0
   859
		err = stmt.BindInt(5, 367);
sl@0
   860
		TEST2(err, KErrNone);
sl@0
   861
		stmt.Close();
sl@0
   862
		CommitTransaction();
sl@0
   863
		}
sl@0
   864
	
sl@0
   865
	TUint32 fc2 = User::FastCounter();
sl@0
   866
	TheHarvestInsertEventTime += TimeDiffUs(fc1, fc2);
sl@0
   867
	}
sl@0
   868
sl@0
   869
void DoHarvestUpdateObjImage()
sl@0
   870
	{
sl@0
   871
	TUint32 fc1 = User::FastCounter();
sl@0
   872
	
sl@0
   873
	_LIT(KSql1, "UPDATE Object1 SET Flags=? ,Origin=?,TimeOffset=?,ItemType=?,Title=? WHERE ObjectId=?;");
sl@0
   874
	_LIT(KSql2, "UPDATE Image1 SET Width=?,Height=?,BitsPerSample=?,FrameCount=? WHERE ObjectId=?;");
sl@0
   875
	
sl@0
   876
	for(TInt i=0;i<KItemCnt;++i)
sl@0
   877
		{
sl@0
   878
		BeginTransaction();
sl@0
   879
		
sl@0
   880
		RSqlStatement stmt1;
sl@0
   881
		TInt err = stmt1.Prepare(TheDb, KSql1);
sl@0
   882
		TEST2(err, KErrNone);
sl@0
   883
		err = stmt1.BindInt(0, 32);
sl@0
   884
		TEST2(err, KErrNone);
sl@0
   885
		err = stmt1.BindInt(1, 1);
sl@0
   886
		TEST2(err, KErrNone);
sl@0
   887
		err = stmt1.BindInt(2, 2);
sl@0
   888
		TEST2(err, KErrNone);
sl@0
   889
		err = stmt1.BindInt(3, 3);
sl@0
   890
		TEST2(err, KErrNone);
sl@0
   891
		TBuf<32> title;
sl@0
   892
		title.Copy(_L("Title-"));
sl@0
   893
		title.AppendNum(i + 1);
sl@0
   894
		err = stmt1.BindText(4, title);
sl@0
   895
		TEST2(err, KErrNone);
sl@0
   896
		err = stmt1.BindInt(5, i + 1);
sl@0
   897
		TEST2(err, KErrNone);
sl@0
   898
		err = stmt1.Exec();
sl@0
   899
		TEST2(err, 1);
sl@0
   900
		stmt1.Close();
sl@0
   901
sl@0
   902
		RSqlStatement stmt2;
sl@0
   903
		err = stmt2.Prepare(TheDb, KSql2);
sl@0
   904
		TEST2(err, KErrNone);
sl@0
   905
		err = stmt2.BindInt(0, 1000);
sl@0
   906
		TEST2(err, KErrNone);
sl@0
   907
		err = stmt2.BindInt(1, 1200);
sl@0
   908
		TEST2(err, KErrNone);
sl@0
   909
		err = stmt2.BindInt(2, 24);
sl@0
   910
		TEST2(err, KErrNone);
sl@0
   911
		err = stmt2.BindInt(3, 3);
sl@0
   912
		TEST2(err, KErrNone);
sl@0
   913
		err = stmt2.BindInt(4, i + 1);
sl@0
   914
		TEST2(err, KErrNone);
sl@0
   915
		err = stmt2.Exec();
sl@0
   916
		TEST2(err, 1);
sl@0
   917
		stmt2.Close();
sl@0
   918
sl@0
   919
		CommitTransaction();
sl@0
   920
		}
sl@0
   921
	
sl@0
   922
	TUint32 fc2 = User::FastCounter();
sl@0
   923
	TheHarvestUpdateObjImageTime += TimeDiffUs(fc1, fc2);
sl@0
   924
	}
sl@0
   925
sl@0
   926
void DoHarvestSelect3()
sl@0
   927
	{
sl@0
   928
	TUint32 fc1 = User::FastCounter();
sl@0
   929
	
sl@0
   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;");
sl@0
   931
	
sl@0
   932
	for(TInt i=0;i<KItemCnt;++i)
sl@0
   933
		{
sl@0
   934
		RSqlStatement stmt;
sl@0
   935
		TInt err = stmt.Prepare(TheDb, KSql1);
sl@0
   936
		TEST2(err, KErrNone);
sl@0
   937
		err = stmt.BindInt(0, 65536);
sl@0
   938
		TEST2(err, KErrNone);
sl@0
   939
		err = stmt.BindInt(1, 65536);
sl@0
   940
		TEST2(err, KErrNone);
sl@0
   941
		err = stmt.BindInt(2, 65536);
sl@0
   942
		TEST2(err, KErrNone);
sl@0
   943
		err = stmt.BindInt(3, 65536);
sl@0
   944
		TEST2(err, KErrNone);
sl@0
   945
		err = stmt.BindInt(4, i + 1);
sl@0
   946
		TEST2(err, KErrNone);
sl@0
   947
		TInt cnt = 0;
sl@0
   948
		while((err = stmt.Next()) == KSqlAtRow)
sl@0
   949
			{
sl@0
   950
			++cnt;
sl@0
   951
			}
sl@0
   952
		TEST2(err, KSqlAtEnd);
sl@0
   953
		TEST2(cnt, 1);
sl@0
   954
		stmt.Close();
sl@0
   955
		}
sl@0
   956
sl@0
   957
	TUint32 fc2 = User::FastCounter();
sl@0
   958
	TheHarvestSelect3Time += TimeDiffUs(fc1, fc2);
sl@0
   959
	}
sl@0
   960
sl@0
   961
void DoHarvestSelect4()
sl@0
   962
	{
sl@0
   963
	TUint32 fc1 = User::FastCounter();
sl@0
   964
	
sl@0
   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=?))));");
sl@0
   966
	
sl@0
   967
	for(TInt i=0;i<KItemCnt;++i)
sl@0
   968
		{
sl@0
   969
		RSqlStatement stmt;
sl@0
   970
		TInt err = stmt.Prepare(TheDb, KSql2);
sl@0
   971
		TEST2(err, KErrNone);
sl@0
   972
		err = stmt.BindInt(0, 65536);
sl@0
   973
		TEST2(err, KErrNone);
sl@0
   974
		err = stmt.BindInt(1, 65536);
sl@0
   975
		TEST2(err, KErrNone);
sl@0
   976
		err = stmt.BindInt(2, 65536);
sl@0
   977
		TEST2(err, KErrNone);
sl@0
   978
		err = stmt.BindInt(3, 65536);
sl@0
   979
		TEST2(err, KErrNone);
sl@0
   980
		err = stmt.BindInt(4, 65536);
sl@0
   981
		TEST2(err, KErrNone);
sl@0
   982
		err = stmt.BindInt(5, i + 1);
sl@0
   983
		TEST2(err, KErrNone);
sl@0
   984
		TInt cnt = 0;
sl@0
   985
		while((err = stmt.Next()) == KSqlAtRow)
sl@0
   986
			{
sl@0
   987
			++cnt;
sl@0
   988
			}
sl@0
   989
		TEST2(err, KSqlAtEnd);
sl@0
   990
		TEST2(cnt, 1);
sl@0
   991
		stmt.Close();
sl@0
   992
		}
sl@0
   993
	
sl@0
   994
	TUint32 fc2 = User::FastCounter();
sl@0
   995
	TheHarvestSelect4Time += TimeDiffUs(fc1, fc2);
sl@0
   996
	}
sl@0
   997
sl@0
   998
void DoHarvestUpdateObj()
sl@0
   999
	{
sl@0
  1000
	TUint32 fc1 = User::FastCounter();
sl@0
  1001
sl@0
  1002
	_LIT(KSql, "UPDATE Object1 SET Flags=Flags&? WHERE ObjectId IN(?);");
sl@0
  1003
	
sl@0
  1004
	for(TInt i=0;i<KItemCnt;++i)
sl@0
  1005
		{
sl@0
  1006
		BeginTransaction();
sl@0
  1007
		RSqlStatement stmt;
sl@0
  1008
		TInt err = stmt.Prepare(TheDb, KSql);
sl@0
  1009
		TEST2(err, KErrNone);
sl@0
  1010
		err = stmt.BindInt(0, 32768);
sl@0
  1011
		TEST2(err, KErrNone);
sl@0
  1012
		err = stmt.BindInt(1, i + 1);
sl@0
  1013
		TEST2(err, KErrNone);
sl@0
  1014
		err = stmt.Exec();
sl@0
  1015
		TEST2(err, 1);
sl@0
  1016
		stmt.Close();
sl@0
  1017
		CommitTransaction();
sl@0
  1018
		}
sl@0
  1019
	
sl@0
  1020
	TUint32 fc2 = User::FastCounter();
sl@0
  1021
	TheHarvestUpdateObjTime += TimeDiffUs(fc1, fc2);
sl@0
  1022
	}
sl@0
  1023
sl@0
  1024
void Harvest()
sl@0
  1025
	{
sl@0
  1026
	TUint32 fc1 = User::FastCounter();	
sl@0
  1027
	DoHarvestSelect();
sl@0
  1028
	DoHarvestInsertObjImage();
sl@0
  1029
	DoHarvestSelect2();
sl@0
  1030
	DoHarvestSelect2();
sl@0
  1031
	DoHarvestSelect2();
sl@0
  1032
	DoHarvestInsertEvent();
sl@0
  1033
	DoHarvestUpdateObjImage();
sl@0
  1034
	DoHarvestSelect3();
sl@0
  1035
	DoHarvestSelect4();
sl@0
  1036
	DoHarvestUpdateObj();
sl@0
  1037
	TUint32 fc2 = User::FastCounter();
sl@0
  1038
	TheHarvestTime += TimeDiffUs(fc1, fc2);
sl@0
  1039
	}
sl@0
  1040
sl@0
  1041
/**
sl@0
  1042
@SYMTestCaseID			PDS-SQL-UT-4150
sl@0
  1043
@SYMTestCaseDesc		MDS harvesting performance test.
sl@0
  1044
						The test reproduces the MDS harvesting actions with the SQL server,
sl@0
  1045
						performed for 1000 images. The time taken for the execution of SQL statements 
sl@0
  1046
						is measured and printed out.
sl@0
  1047
@SYMTestActions			MDS harvesting performance test.
sl@0
  1048
@SYMTestExpectedResults Test must not fail
sl@0
  1049
@SYMTestPriority		High
sl@0
  1050
@SYMDEF					DEF142327
sl@0
  1051
*/
sl@0
  1052
void PrintResults()
sl@0
  1053
	{
sl@0
  1054
	TheTest.Printf(_L("==Fast counter frequency=%d Hz\r\n"), TheFastCounterFreq);
sl@0
  1055
	TheTest.Printf(_L("==Create database, time=%d us\r\n"), TheCreateDbCreateConnTime);
sl@0
  1056
	TheTest.Printf(_L("==Open database, time=%d us\r\n"), TheCreateDbOpenConnTime);
sl@0
  1057
	TheTest.Printf(_L("=='SELECT max(seq) FROM SQLITE_SEQUENCE', time=%d us\r\n"), TheLastItemIdTime);
sl@0
  1058
	TheTest.Printf(_L("=='SELECT COUNT(*) FROM MdE_Preferences', time=%d us\r\n"), TheTableExistsTime);
sl@0
  1059
	TheTest.Printf(_L("==MDE tables creation, time=%d us\r\n"), TheMdeTablesCreationTime);
sl@0
  1060
	TheTest.Printf(_L("=='SELECT last_insert_rowid()', time=%d us\r\n"), TheLastInsertedRowIdTime);
sl@0
  1061
	TheTest.Printf(_L("==1.Create tables, time=%d us\r\n"), TheCreateTables1Time);
sl@0
  1062
	TheTest.Printf(_L("==2.Create tables, time=%d us\r\n"), TheCreateTables2Time);
sl@0
  1063
	TheTest.Printf(_L("==3.Create tables, time=%d us\r\n"), TheCreateTables3Time);
sl@0
  1064
	TheTest.Printf(_L("==InsertEventRelation, time=%d us\r\n"), TheInsertEventRelationTime);
sl@0
  1065
	TheTest.Printf(_L("==Create triggers, time=%d us\r\n"), TheCreateTriggersTime);
sl@0
  1066
	TheTest.Printf(_L("==DeleteObjectProperty, time=%d us\r\n"), TheDeleteObjPropertyTime);
sl@0
  1067
	TheTest.Printf(_L("==InsertCol2Property, time=%d us\r\n"), TheInsertCol2PropTime);
sl@0
  1068
	TheTest.Printf(_L("==The create transaction, time=%d us\r\n"), TheTransactionTime);
sl@0
  1069
	TheTest.Printf(_L("==Database create schema, time=%d us\r\n"), TheDbCreateTime);
sl@0
  1070
sl@0
  1071
	TheTest.Printf(_L("==HarvestSelect, time=%d us\r\n"), TheHarvestSelectTime);
sl@0
  1072
	TheTest.Printf(_L("==HarvestInsertObjImage, time=%d us\r\n"), TheHarvestInsertObjImageTime);
sl@0
  1073
	TheTest.Printf(_L("==HarvestSelect2, time=%d us\r\n"), TheHarvestSelect2Time);
sl@0
  1074
	TheTest.Printf(_L("==HarvestSelect3, time=%d us\r\n"), TheHarvestSelect3Time);
sl@0
  1075
	TheTest.Printf(_L("==HarvestSelect4, time=%d us\r\n"), TheHarvestSelect4Time);
sl@0
  1076
	TheTest.Printf(_L("==HarvestInsertEvent, time=%d us\r\n"), TheHarvestInsertEventTime);
sl@0
  1077
	TheTest.Printf(_L("==HarvestUpdateObjImage, time=%d us\r\n"), TheHarvestUpdateObjImageTime);
sl@0
  1078
	TheTest.Printf(_L("==HarvestUpdateObj, time=%d us\r\n"), TheHarvestUpdateObjTime);
sl@0
  1079
	TheTest.Printf(_L("==Harvest, time=%d us\r\n"), TheHarvestTime);
sl@0
  1080
	}
sl@0
  1081
sl@0
  1082
void DoTestsL()
sl@0
  1083
	{
sl@0
  1084
	CalcIterationsCount();
sl@0
  1085
	
sl@0
  1086
	TheTestTitle.Format(_L("@SYMTestCaseID:PDS-SQL-UT-4149 Create database, encoding: \"%S\", page size: %d\r\n"), 
sl@0
  1087
			TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
sl@0
  1088
	TheTest.Start(TheTestTitle);
sl@0
  1089
	CreateDb();
sl@0
  1090
sl@0
  1091
	TheTestTitle.Format(_L("@SYMTestCaseID:PDS-SQL-UT-4150 Harvest %d items, encoding: \"%S\", page size: %d\r\n"), 
sl@0
  1092
			KItemCnt, TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
sl@0
  1093
	TheTest.Next(TheTestTitle);
sl@0
  1094
	Harvest();
sl@0
  1095
	
sl@0
  1096
	PrintResults();
sl@0
  1097
	}
sl@0
  1098
sl@0
  1099
TInt E32Main()
sl@0
  1100
	{
sl@0
  1101
	TheTest.Title();
sl@0
  1102
sl@0
  1103
	CTrapCleanup* tc = CTrapCleanup::New();
sl@0
  1104
	TheTest(tc != NULL);
sl@0
  1105
	
sl@0
  1106
	__UHEAP_MARK;
sl@0
  1107
sl@0
  1108
	GetCmdLineParamsAndSqlConfigString(TheTest, _L("t_sqlperformance3"), TheCmdLineParams, TheSqlConfigString);
sl@0
  1109
	PrepareDbName(KDbName, TheCmdLineParams.iDriveName, TheDbFileName);
sl@0
  1110
sl@0
  1111
	TheTest.Printf(_L("==Databases: %S\r\n"), &TheDbFileName); 
sl@0
  1112
	
sl@0
  1113
	TestEnvDestroy();
sl@0
  1114
	TestEnvInit();
sl@0
  1115
	TRAPD(err, DoTestsL());
sl@0
  1116
	TestEnvDestroy();
sl@0
  1117
	TEST2(err, KErrNone);
sl@0
  1118
sl@0
  1119
	__UHEAP_MARKEND;
sl@0
  1120
	
sl@0
  1121
	TheTest.End();
sl@0
  1122
	TheTest.Close();
sl@0
  1123
	
sl@0
  1124
	delete tc;
sl@0
  1125
sl@0
  1126
	User::Heap().Check();
sl@0
  1127
	return KErrNone;
sl@0
  1128
	}