Update contrib.
1 // Copyright (c) 2008-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.
23 #include "sqliteTestUtl.h"
25 ///////////////////////////////////////////////////////////////////////////////////////
33 EPerfTestSingleInsert,
34 EPerfTestSingleUpdate,
35 EPerfTestSingleDelete,
36 EPerfTestSingleSelect,
41 //The performance test case results are stored in the ThePerfTestResult array.
42 static TUint32 ThePerfTestResult[EPerfTestTypeCnt];
44 const char* const KTestName = "t_sqliteperf2 test";
46 _LIT(KTestDir, "c:\\test\\");
47 _LIT(KTestDbName, "c:\\test\\t_sqliteperf2.db");
48 const char KTestDbName8[] = "c:\\test\\t_sqliteperf2.db";
54 const TInt KInsertRecCnt = 1000;
56 const TInt KUpdateRecCnt = KInsertRecCnt / 10;
57 const TInt KDeleteRecCnt = KInsertRecCnt / 10;
58 const TInt KSelectRecCnt = KInsertRecCnt / 10;
60 const TInt KInsertRecIds[KInsertRecCnt] =
62 18920,515,22944,32238,20164,9592,32360,29280,6219,26241,11175,15824,20409,14659,30084,4630,21646,24582,12976,21104,1834,
63 23425,15260,9692,8601,12375,10729,2244,4784,9697,11296,8672,3929,25134,16803,24153,20011,1864,29411,6442,8510,
64 13753,22996,20940,25149,6222,3742,13842,25788,23835,19606,850,25292,16319,25452,709,6093,2282,18597,9520,32132,
65 10012,23884,452,24430,17583,15333,15427,14419,32535,8867,5733,3613,9065,19931,12410,16363,5146,22199,15696,31330,
66 15369,27183,11607,17987,12992,27701,5379,25923,30199,23344,21106,28951,23642,1964,13903,28878,9613,29776,13302,22627,
67 19308,29200,23769,9875,30871,19620,11042,5356,18478,6968,24474,3623,13017,2405,30409,24247,19724,11360,31071,21410,
68 14985,14449,11218,15248,31526,10919,24905,32289,29904,15051,30137,15748,24272,10642,13133,13894,29261,16150,9996,20839,
69 1042,3463,10422,7347,27538,19486,6638,7503,23337,24147,8350,12435,3493,23376,24728,28439,27909,10661,30841,17937,
70 5761,829,17875,15070,24522,30097,13451,3294,16786,12827,7551,10629,19279,17166,30828,9903,1084,30788,25872,14132,
71 23969,8312,20363,19901,6741,25269,13323,25046,20353,19470,17832,2884,25254,26000,31885,26520,10466,26229,20313,32260,
72 2927,22170,7109,5486,21868,13620,646,12483,3808,30654,14965,9614,2300,30006,7917,201,32672,4488,32116,11762,
73 29729,15691,26270,5218,9546,7595,1583,7899,18592,28838,18048,24928,26858,380,17188,20809,3569,16736,20170,17302,
74 4485,22644,4197,9604,17856,17140,31627,9054,20623,20145,10267,12694,24685,3266,19747,11284,7794,2934,25345,32718,
75 397,27789,12488,4761,26382,18661,23870,5223,10492,14594,27601,1587,19534,28970,14398,12407,21532,9774,4901,5160,
76 9497,13128,3816,19950,11740,16127,8450,552,10058,28058,18992,5776,30968,29015,1760,29188,30287,32119,15445,4463,
77 28916,14875,23282,10548,31499,8933,6568,22293,13214,12741,17781,17318,12867,11280,10795,30721,22009,30835,15292,31572,
78 3942,19729,3864,24026,24900,15722,5499,10412,14873,3395,1057,31337,17181,29131,26894,24655,28321,1500,24135,3235,
79 25831,21374,32065,19539,13111,5805,9882,32731,28975,7516,29191,7013,20571,26809,23182,29236,18950,29619,31477,20802,
80 24399,17081,28282,11560,8063,8389,10692,26431,26777,11674,24602,28165,5683,8522,18643,15554,4741,26874,22797,32363,
81 32192,233,17826,22470,24481,12207,24920,7375,5957,1731,11096,30043,32063,19520,8674,13563,27624,12777,11582,27171,
82 8694,32106,14070,26763,13136,1505,16706,21206,31777,10908,4804,26482,18987,10020,19061,5311,12383,26747,28640,6259,
83 14506,18339,21390,11837,26641,19807,21441,4520,18688,25406,22885,22339,28639,5588,8515,24831,11751,19531,29144,26164,
84 6427,15141,9399,14619,2069,14441,19095,31165,3494,13964,29671,8668,31578,17533,10544,14318,7583,5880,23408,26316,
85 14367,12518,27517,19297,16745,4135,31647,13200,22619,4367,2789,9725,7578,29700,12598,4035,27492,1432,14052,19895,
86 18886,4597,19076,23280,29455,10110,18686,18567,31876,27827,19424,25243,30549,3413,29176,9880,7632,715,5665,28345,
87 24789,15301,26717,30412,27018,26399,7460,7734,25423,26120,9980,2870,8693,10595,11850,4974,30762,32365,15208,3487,
88 21048,3745,18167,28852,26864,5849,9335,25602,8416,6581,31509,9422,27085,4416,16579,25871,12893,25553,27534,1910,
89 17427,8240,19756,23724,7040,17658,19669,17883,4280,5959,29525,24687,25604,19593,32094,7966,726,3000,26658,29733,
90 6402,2476,11297,28885,16938,17610,6720,32335,28538,9186,3868,5004,21910,31832,28829,3232,30417,17282,10702,1855,
91 7584,28498,6380,26752,23374,18997,9149,28641,24305,15930,26146,14492,23415,12016,25048,23766,7593,16124,1043,31819,
92 13594,32373,32383,962,22216,7287,6554,22607,22467,19676,24738,9162,6103,6230,345,17791,32619,29371,22790,15143,
93 5289,2975,21180,5656,27615,3368,31454,20664,30501,15646,27619,6199,31041,13378,30807,24190,8135,8161,13858,18530,
94 2181,16808,20237,13853,8634,14978,5120,14324,9984,17555,31074,2379,2496,1599,11228,27564,21618,13040,22712,16520,
95 26319,24391,26278,9758,12074,9500,6577,23454,3587,18625,13170,12431,6106,17287,25476,878,10561,22404,7224,5016,
96 309,4243,8073,10858,21934,22171,22610,24486,5749,29973,21438,32024,21046,15304,28416,17786,29142,7383,3397,8854,
97 15878,27646,27111,32426,25369,8985,23268,19728,26386,20454,6030,1566,17922,3851,6732,10385,14427,24032,8340,26842,
98 8277,17586,17439,22908,4845,7342,13597,749,27536,13601,8437,19218,28258,8234,30110,15117,18122,18214,29772,22359,
99 20272,9068,22352,15886,1541,28475,3897,32656,21508,25328,23360,25928,1976,21116,16611,6856,10815,9935,27928,4429,
100 12589,5891,5198,21108,27699,15199,31650,24882,28266,14901,13547,16697,8948,13826,12168,22678,21371,7123,1568,29161,
101 4208,10600,29255,18437,12973,30787,31557,2465,8280,536,17745,22794,15587,20156,20917,3376,951,681,1520,5078,
102 5278,22108,22739,32389,14749,10621,17753,643,24374,31027,5357,22242,6921,5171,27844,6164,13191,5047,31615,2889,
103 9720,22901,20304,11257,19906,22367,14268,4328,13897,5228,11362,13777,11327,15541,27712,17995,7128,22298,31944,9167,
104 19254,4479,4957,12551,18927,22130,25701,13453,22721,26125,26783,22774,31105,30238,3254,28175,15189,7558,20326,5923,
105 3807,4096,5132,28745,26210,22490,27546,3471,3847,6089,19570,7769,2177,22343,8226,27389,2907,5088,14373,25035,
106 29096,27416,21853,23996,20037,554,11952,1646,1392,23339,29032,31060,3801,24280,13282,16801,7676,13202,138,1896,
107 9391,1447,3335,14849,25591,9427,29106,14766,32544,6919,30029,17534,17677,8296,16626,10866,9164,4251,4169,3295,
108 31341,17728,12798,11539,15637,31164,27762,3643,8014,7228,6833,28293,14497,12279,5541,22375,9395,15753,26061,30172,
109 18314,14239,14321,1397,12526,13350,5256,1140,21483,20615,32673,4537,4780,27087,5988,29403,31809,29537,24569,16503,
110 6047,9709,1701,11464,24552,6812,24630,6264,21997,9869,9890,27062,19186,2693,14827,22921,18609,19170,26693,11108,
111 15009,17361,379,762,15479,19905,14735,12781,1560,7841,27168,3011,4132,9745,7756,24068,25172,5352,24787
114 const TInt KUpdateRecIds[KUpdateRecCnt] =
116 6638,22607,5776,31477,10815,6919,32116,31041,18609,7224,18167,12992,11751,22721,29619,21048,22170,30084,23408,26278,
117 8437,9164,31509,552,16786,10544,29776,9604,26061,18314,23360,2884,11762,25134,31526,17826,29131,15753,12827,4035,5849,
118 8073,25788,27789,7516,19905,18478,2465,5289,13601,4784,13453,7583,309,9725,16503,14321,30835,14849,29236,19539,27087,
119 32365,29176,138,23642,9745,9880,28175,17555,12867,22921,17987,17318,15117,6554,17781,3569,23337,380,27085,24522,17583,
120 27844,19676,21618,30137,9520,24272,1541,32718,6030,25604,28282,15333,20037,10858,31777,18048,16706
123 const TInt KSelectRecIds[KSelectRecCnt] =
125 5683,4367,1432,9725,15824,6030,16697,5379,26520,1447,21116,17728,2927,11362,30172,11228,32260,15930,25292,17753,12867,
126 17534,12488,26164,3745,31164,30287,6230,16319,27909,6577,3471,5988,24272,2069,26270,21532,7769,23344,18987,6921,536,6164,
127 30199,11108,3847,4597,28266,31509,31819,8510,12777,14449,31650,9996,7460,30412,24147,10908,19906,31876,24247,6732,5957,
128 10815,17995,23337,7584,12383,26858,5665,11850,5749,5088,5486,643,13826,32094,15886,21910,4520,4630,7516,10110,24687,7558,
129 22627,27171,14492,11175,18688,27546,27087,29772,20353,9520,15878,25046,15696,22921,
132 const TInt KDeleteRecIds[KDeleteRecCnt] =
134 20623,19095,26210,18048,8416,18167,13200,22944,1057,31337,17875,29973,1140,23374,24552,19931,13017,10385,10058,11360,
135 30029,6581,22170,15824,2300,32389,25345,3494,17302,3807,19728,17832,11362,27909,30006,17361,28266,16319,22908,27564,
136 13853,24026,17586,25269,646,15141,15753,24655,22644,9882,9725,26763,6968,29191,27087,26864,13620,23884,27789,8161,643,
137 27062,1447,14506,29619,24153,8312,32544,31060,18530,13753,13826,8933,23408,20615,7013,18122,233,27712,536,3942,28852,
138 22921,31876,9613,397,26717,18997,23835,15292,5891,30968,24685,30835,29537,15051,13128,31477,28416,8135
141 const TInt KInsertRecId = 6184;
142 const TInt KUpdateRecId = 26658;
143 const TInt KSelectRecId = 9592;
144 const TInt KDeleteRecId = 24481;
146 const char KMultiInsertSql[] = "INSERT INTO Tbl VALUES(:Id, 9234567890, 99.998, 'TEXT VALUE', x'AABBCCDDEEFF')";
147 const char KMultiUpdateSql[] = "UPDATE Tbl SET D=11.113 WHERE I IN";
148 const char KMultiDeleteSql[] = "DELETE FROM Tbl WHERE I IN";
149 const char KMultiSelectSql[] = "SELECT I64,D,T,B FROM Tbl WHERE I IN";
151 const char KSingleInsertSql[] = "INSERT INTO Tbl VALUES(%d, 9234567890, 99.998, 'TEXT VALUE', x'AABBCCDDEEFF')";
152 const char KSingleUpdateSql[] = "UPDATE Tbl SET D=11.113 WHERE I=";
153 const char KSingleDeleteSql[] = "DELETE FROM Tbl WHERE I=";
154 const char KSingleSelectSql[] = "SELECT I64,D,T,B FROM Tbl WHERE I=";
156 //This buffer is used for SQL statement formatting. 2000 bytes should be enough as a buffer max length.
157 static char TheSqlBuf[2000];
158 //This buffer is used for printf related formatting. 500 characters should be enough.
159 static TBuf<500> ThePrintBuf;
161 #define UNUSED_VAR(a) (a) = (a)
162 #define UNUSED_PTR(a) a.Set(a)
164 ///////////////////////////////////////////////////////////////////////////////////////
166 static void DeleteTestFiles()
168 (void)TheFs.Delete(KTestDbName);
171 ///////////////////////////////////////////////////////////////////////////////////////
172 static void PrintSqliteErrMsg()
176 const char* msg = sqlite3_errmsg(TheDb);
177 TestPrintf("*** SQLite error message:");
182 //Test macros and functions
183 static void Check(TInt aValue, TInt aLine)
189 TestTestLine(EFalse, aLine);
192 static void Check(TInt aValue, TInt aExpected, TInt aLine)
194 if(aValue != aExpected)
197 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
199 TestTestLine(EFalse, aLine);
202 #define TEST(arg) ::Check((arg), __LINE__)
203 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
205 ///////////////////////////////////////////////////////////////////////////////////////
207 static TInt TheCounterFreq = -10000000;
208 const TInt KMicroSecIn1Sec = 1000000;
210 //Prints aFastCount parameter (converted to us)
211 static TInt FcDiff2Us(TUint32 aFastCount)
213 double v = ((double)aFastCount * KMicroSecIn1Sec) / (double)TheCounterFreq;
218 static void GetFastCounterFrequency()
220 TEST2(HAL::Get(HAL::EFastCounterFrequency, TheCounterFreq), KErrNone);
221 TBuf8<32> printString;
222 printString.Format(_L8("Counter frequency=%d\r\n"), TheCounterFreq);
223 TestPrintf((const char*)printString.PtrZ());
226 TUint32 FastCounterValue(void)
228 return User::FastCounter();
231 void StorePerfTestResult(TPerfTestType aType, TUint32 aStartTicks, TUint32 aEndTicks)
233 TInt64 diffTicks = (TInt64)aEndTicks - (TInt64)aStartTicks;
236 diffTicks = KMaxTUint32 + diffTicks + 1;
238 ThePerfTestResult[aType] = (TUint32)diffTicks;
241 static void PrintPerfTestResults()
243 TBuf8<256> printString;
245 TInt r = FcDiff2Us(ThePerfTestResult[EPerfTestMultiInsert]);
246 printString.Format(_L8("###Mutli Insert: %8dus\r\n"), r);
247 TestPrintf((const char*)printString.PtrZ());
249 r = FcDiff2Us(ThePerfTestResult[EPerfTestMultiUpdate]);
250 printString.Format(_L8("###Mutli Update: %8dus\r\n"), r);
251 TestPrintf((const char*)printString.PtrZ());
253 r = FcDiff2Us(ThePerfTestResult[EPerfTestMultiSelect]);
254 printString.Format(_L8("###Mutli Select: %8dus\r\n"), r);
255 TestPrintf((const char*)printString.PtrZ());
257 r = FcDiff2Us(ThePerfTestResult[EPerfTestMultiDelete]);
258 printString.Format(_L8("###Mutli Delete: %8dus\r\n"), r);
259 TestPrintf((const char*)printString.PtrZ());
262 r = FcDiff2Us(ThePerfTestResult[EPerfTestSingleInsert]);
263 printString.Format(_L8("##Single Insert: %8dus\r\n"), r);
264 TestPrintf((const char*)printString.PtrZ());
266 r = FcDiff2Us(ThePerfTestResult[EPerfTestSingleUpdate]);
267 printString.Format(_L8("##Single Update: %8dus\r\n"), r);
268 TestPrintf((const char*)printString.PtrZ());
270 r = FcDiff2Us(ThePerfTestResult[EPerfTestSingleSelect]);
271 printString.Format(_L8("##Single Select: %8dus\r\n"), r);
272 TestPrintf((const char*)printString.PtrZ());
274 r = FcDiff2Us(ThePerfTestResult[EPerfTestSingleDelete]);
275 printString.Format(_L8("##Single Delete: %8dus\r\n"), r);
276 TestPrintf((const char*)printString.PtrZ());
279 ///////////////////////////////////////////////////////////////////////////////////////
281 static void CreateTestDir()
283 TInt err = TheFs.MkDir(KTestDir);
284 TEST(err == KErrNone || err == KErrAlreadyExists);
287 static void CreateTestDatabase()
289 (void)TheFs.Delete(KTestDbName);
291 const char* ver = sqlite3_libversion();
292 TestPrintf("*** SQLite library version:");
295 TInt err = sqlite3_open(KTestDbName8, &TheDb);
296 TEST2(err, SQLITE_OK);
298 err = sqlite3_exec(TheDb, "CREATE TABLE Tbl(I INTEGER PRIMARY KEY, I64 BIGINT, D DOUBLE, T TEXT, B BINARY)", 0, 0, 0);
299 TEST2(err, SQLITE_OK);
301 sqlite3_close(TheDb);
305 ///////////////////////////////////////////////////////////////////////////////////////
308 @SYMTestCaseID PDS-SQLITE3-UT-4030
309 @SYMTestCaseDesc SQLite library multi-insert performance test.
310 The test inserts 1000 records in a single transaction and stores
311 the execution time for later use (comparison and printing).
312 The main purpose of this test is - regression performance testing.
313 @SYMTestPriority High
314 @SYMTestActions SQLite library multi-insert performance test.
315 @SYMTestExpectedResults Test must not fail
318 static void SqliteMultiInsertTest()
320 const char* tail = 0;
321 sqlite3_stmt* stmt = 0;
324 TInt err = sqlite3_open(KTestDbName8, &TheDb);
325 TEST2(err, SQLITE_OK);
327 err = sqlite3_prepare(TheDb, KMultiInsertSql, -1, &stmt, &tail);
328 TEST2(err, SQLITE_OK);
330 TUint32 fc = FastCounterValue();
331 err = sqlite3_exec(TheDb, "BEGIN", 0, 0, 0);
332 TEST2(err, SQLITE_OK);
334 for(TInt i=0;i<KInsertRecCnt;++i)
336 err = sqlite3_bind_int(stmt, 1, KInsertRecIds[i]);
337 TEST2(err, SQLITE_OK);
339 err = sqlite3_step(stmt);
340 TEST2(err, SQLITE_DONE);
342 err = sqlite3_reset(stmt);
343 TEST2(err, SQLITE_OK);
346 err = sqlite3_exec(TheDb, "COMMIT", 0, 0, 0);
347 TEST2(err, SQLITE_OK);
349 StorePerfTestResult(EPerfTestMultiInsert, fc, FastCounterValue());
351 sqlite3_finalize(stmt);
352 sqlite3_close(TheDb);
356 static void FormatSqlStmt(const char aSql[], const TInt aRecIds[], const TInt aRecCnt)
358 strcpy(TheSqlBuf, aSql);
359 strcat(TheSqlBuf, "(");
360 for(TInt i=0;i<aRecCnt;++i)
363 sprintf(tmp, "%d,", aRecIds[i]);
364 strcat(TheSqlBuf, tmp);
366 TheSqlBuf[strlen(TheSqlBuf) - 1] = ')';
370 @SYMTestCaseID PDS-SQLITE3-UT-4031
371 @SYMTestCaseDesc SQLite library multi-update performance test.
372 The test updates 100 records and stores
373 the execution time for later use (comparison and printing).
374 The main purpose of this test is - regression performance testing.
375 @SYMTestPriority High
376 @SYMTestActions SQLite library multi-update performance test.
377 @SYMTestExpectedResults Test must not fail
380 static void SqliteMultiUpdateTest()
383 TInt err = sqlite3_open(KTestDbName8, &TheDb);
384 TEST2(err, SQLITE_OK);
386 FormatSqlStmt(KMultiUpdateSql, KUpdateRecIds, KUpdateRecCnt);
388 TUint32 fc = FastCounterValue();
390 err = sqlite3_exec(TheDb, TheSqlBuf, 0, 0, 0);
391 TEST2(err, SQLITE_OK);
393 StorePerfTestResult(EPerfTestMultiUpdate, fc, FastCounterValue());
395 TInt cnt = sqlite3_changes(TheDb);
396 TEST2(cnt, KUpdateRecCnt);
398 sqlite3_close(TheDb);
403 @SYMTestCaseID PDS-SQLITE3-UT-4032
404 @SYMTestCaseDesc SQLite library multi-select performance test.
405 The test selects 100 records and stores
406 the execution time for later use (comparison and printing).
407 The main purpose of this test is - regression performance testing.
408 @SYMTestPriority High
409 @SYMTestActions SQLite library multi-select performance test.
410 @SYMTestExpectedResults Test must not fail
413 static void SqliteMultiSelectTest()
415 const char* tail = 0;
416 sqlite3_stmt* stmt = 0;
419 TInt err = sqlite3_open(KTestDbName8, &TheDb);
420 TEST2(err, SQLITE_OK);
422 FormatSqlStmt(KMultiSelectSql, KSelectRecIds, KSelectRecCnt);
424 err = sqlite3_prepare(TheDb, TheSqlBuf, -1, &stmt, &tail);
425 TEST2(err, SQLITE_OK);
427 TUint32 fc = FastCounterValue();
430 while((err = sqlite3_step(stmt)) == SQLITE_ROW)
434 const unsigned short* t;
435 const unsigned char* b;
437 i64 = sqlite3_column_int64(stmt, 0);
439 d = sqlite3_column_double(stmt, 1);
441 t = (const unsigned short*)sqlite3_column_text16(stmt, 2);
443 b = (const unsigned char*)sqlite3_column_blob(stmt, 3);
447 TEST2(err, SQLITE_DONE);
448 TEST2(recCnt, KSelectRecCnt);
450 StorePerfTestResult(EPerfTestMultiSelect, fc, FastCounterValue());
452 sqlite3_finalize(stmt);
453 sqlite3_close(TheDb);
458 @SYMTestCaseID PDS-SQLITE3-UT-4033
459 @SYMTestCaseDesc SQLite library multi-delete performance test.
460 The test deletes 100 records and stores
461 the execution time for later use (comparison and printing).
462 The main purpose of this test is - regression performance testing.
463 @SYMTestPriority High
464 @SYMTestActions SQLite library multi-delete performance test.
465 @SYMTestExpectedResults Test must not fail
468 static void SqliteMultiDeleteTest()
471 TInt err = sqlite3_open(KTestDbName8, &TheDb);
472 TEST2(err, SQLITE_OK);
474 FormatSqlStmt(KMultiDeleteSql, KDeleteRecIds, KDeleteRecCnt);
476 TUint32 fc = FastCounterValue();
478 err = sqlite3_exec(TheDb, TheSqlBuf, 0, 0, 0);
479 TEST2(err, SQLITE_OK);
481 StorePerfTestResult(EPerfTestMultiDelete, fc, FastCounterValue());
483 TInt cnt = sqlite3_changes(TheDb);
484 TEST2(cnt, KDeleteRecCnt);
486 sqlite3_close(TheDb);
491 @SYMTestCaseID PDS-SQLITE3-UT-4034
492 @SYMTestCaseDesc SQLite library single-insert performance test.
493 The test inserts one record and stores
494 the execution time for later use (comparison and printing).
495 The main purpose of this test is - regression performance testing.
496 @SYMTestPriority High
497 @SYMTestActions SQLite library single-insert performance test.
498 @SYMTestExpectedResults Test must not fail
501 static void SqliteSingleInsertTest()
504 TInt err = sqlite3_open(KTestDbName8, &TheDb);
505 TEST2(err, SQLITE_OK);
507 sprintf(TheSqlBuf, KSingleInsertSql, KInsertRecId);
509 TUint32 fc = FastCounterValue();
511 err = sqlite3_exec(TheDb, TheSqlBuf, 0, 0, 0);
512 TEST2(err, SQLITE_OK);
514 StorePerfTestResult(EPerfTestSingleInsert, fc, FastCounterValue());
516 TInt cnt = sqlite3_changes(TheDb);
519 sqlite3_close(TheDb);
524 @SYMTestCaseID PDS-SQLITE3-UT-4035
525 @SYMTestCaseDesc SQLite library single-update performance test.
526 The test updates one record and stores
527 the execution time for later use (comparison and printing).
528 The main purpose of this test is - regression performance testing.
529 @SYMTestPriority High
530 @SYMTestActions SQLite library single-update performance test.
531 @SYMTestExpectedResults Test must not fail
534 static void SqliteSingleUpdateTest()
537 TInt err = sqlite3_open(KTestDbName8, &TheDb);
538 TEST2(err, SQLITE_OK);
541 sprintf(tmp, "%d", KUpdateRecId);
542 strcpy(TheSqlBuf, KSingleUpdateSql);
543 strcat(TheSqlBuf, tmp);
545 TUint32 fc = FastCounterValue();
547 err = sqlite3_exec(TheDb, TheSqlBuf, 0, 0, 0);
548 TEST2(err, SQLITE_OK);
550 StorePerfTestResult(EPerfTestSingleUpdate, fc, FastCounterValue());
552 TInt cnt = sqlite3_changes(TheDb);
555 sqlite3_close(TheDb);
560 @SYMTestCaseID PDS-SQLITE3-UT-4036
561 @SYMTestCaseDesc SQLite library single-select performance test.
562 The test selects one record and stores
563 the execution time for later use (comparison and printing).
564 The main purpose of this test is - regression performance testing.
565 @SYMTestPriority High
566 @SYMTestActions SQLite library single-select performance test.
567 @SYMTestExpectedResults Test must not fail
570 static void SqliteSingleSelectTest()
572 const char* tail = 0;
573 sqlite3_stmt* stmt = 0;
576 TInt err = sqlite3_open(KTestDbName8, &TheDb);
577 TEST2(err, SQLITE_OK);
580 sprintf(tmp, "%d", KSelectRecId);
581 strcpy(TheSqlBuf, KSingleSelectSql);
582 strcat(TheSqlBuf, tmp);
584 err = sqlite3_prepare(TheDb, TheSqlBuf, -1, &stmt, &tail);
585 TEST2(err, SQLITE_OK);
587 TUint32 fc = FastCounterValue();
590 while((err = sqlite3_step(stmt)) == SQLITE_ROW)
594 const unsigned short* t;
595 const unsigned char* b;
597 i64 = sqlite3_column_int64(stmt, 0);
599 d = sqlite3_column_double(stmt, 1);
601 t = (const unsigned short*)sqlite3_column_text16(stmt, 2);
603 b = (const unsigned char*)sqlite3_column_blob(stmt, 3);
607 TEST2(err, SQLITE_DONE);
610 StorePerfTestResult(EPerfTestSingleSelect, fc, FastCounterValue());
612 sqlite3_finalize(stmt);
613 sqlite3_close(TheDb);
618 @SYMTestCaseID PDS-SQLITE3-UT-4037
619 @SYMTestCaseDesc SQLite library single-delete performance test.
620 The test deletes one record and stores
621 the execution time for later use (comparison and printing).
622 The main purpose of this test is - regression performance testing.
623 @SYMTestPriority High
624 @SYMTestActions SQLite library single-delete performance test.
625 @SYMTestExpectedResults Test must not fail
628 void SqliteSingleDeleteTest()
631 TInt err = sqlite3_open(KTestDbName8, &TheDb);
632 TEST2(err, SQLITE_OK);
635 sprintf(tmp, "%d", KDeleteRecId);
636 strcpy(TheSqlBuf, KSingleDeleteSql);
637 strcat(TheSqlBuf, tmp);
639 TUint32 fc = FastCounterValue();
641 err = sqlite3_exec(TheDb, TheSqlBuf, 0, 0, 0);
642 TEST2(err, SQLITE_OK);
644 StorePerfTestResult(EPerfTestSingleDelete, fc, FastCounterValue());
646 TInt cnt = sqlite3_changes(TheDb);
649 sqlite3_close(TheDb);
653 ///////////////////////////////////////////////////////////////////////////////////////
655 static void DoTests()
657 TestStart("Get fast counter frequency");
658 GetFastCounterFrequency();
660 TestNext("SQLite: Create the test database");
661 CreateTestDatabase();
665 msgbuf.Format(_L8("@SYMTestCaseID:PDS-SQLITE3-UT-4030: Insert %d records in a single transaction"), KInsertRecCnt);
666 TestNext((const char*)msgbuf.PtrZ());
667 SqliteMultiInsertTest();
669 msgbuf.Format(_L8("@SYMTestCaseID:PDS-SQLITE3-UT-4031: Update %d records in a single transaction"), KUpdateRecCnt);
670 TestNext((const char*)msgbuf.PtrZ());
671 SqliteMultiUpdateTest();
673 msgbuf.Format(_L8("@SYMTestCaseID:PDS-SQLITE3-UT-4032: Select %d records"), KSelectRecCnt);
674 TestNext((const char*)msgbuf.PtrZ());
675 SqliteMultiSelectTest();
677 msgbuf.Format(_L8("@SYMTestCaseID:PDS-SQLITE3-UT-4033: Delete %d records in a single transaction"), KDeleteRecCnt);
678 TestNext((const char*)msgbuf.PtrZ());
679 SqliteMultiDeleteTest();
681 msgbuf.Format(_L8("@SYMTestCaseID:PDS-SQLITE3-UT-4034: Insert a single record"));
682 TestNext((const char*)msgbuf.PtrZ());
683 SqliteSingleInsertTest();
685 msgbuf.Format(_L8("@SYMTestCaseID:PDS-SQLITE3-UT-4035: Update a single record"));
686 TestNext((const char*)msgbuf.PtrZ());
687 SqliteSingleUpdateTest();
689 msgbuf.Format(_L8("@SYMTestCaseID:PDS-SQLITE3-UT-4036: Select a single record"));
690 TestNext((const char*)msgbuf.PtrZ());
691 SqliteSingleSelectTest();
693 msgbuf.Format(_L8("@SYMTestCaseID:PDS-SQLITE3-UT-4037: Delete a single record"));
694 TestNext((const char*)msgbuf.PtrZ());
695 SqliteSingleDeleteTest();
697 (void)TheFs.Delete(KTestDbName);
699 PrintPerfTestResults();
707 CTrapCleanup* tc = CTrapCleanup::New();
711 TInt err = TheFs.Connect();
712 TestTest(err == KErrNone);
727 User::Heap().Check();