sl@0
|
1 |
// Copyright (c) 2008-2009 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:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <e32test.h>
|
sl@0
|
17 |
#include <bautils.h>
|
sl@0
|
18 |
#include <e32math.h>
|
sl@0
|
19 |
#include <hal.h>
|
sl@0
|
20 |
#include <sqldb.h>
|
sl@0
|
21 |
#include "sqliteTestUtl.h"
|
sl@0
|
22 |
#include "t_sqliteperf.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
25 |
|
sl@0
|
26 |
const char* const KTestName = "t_sqliteperf test";
|
sl@0
|
27 |
|
sl@0
|
28 |
_LIT(KTestDir, "c:\\test\\");
|
sl@0
|
29 |
_LIT(KTestDbName, "c:\\test\\t_sqliteperf.db");
|
sl@0
|
30 |
_LIT8(KTestDbName8, "c:\\test\\t_sqliteperf.db\x0");
|
sl@0
|
31 |
|
sl@0
|
32 |
_LIT(KSqlSrvName, "sqlsrv.exe");
|
sl@0
|
33 |
|
sl@0
|
34 |
static RSqlDatabase TheDb;
|
sl@0
|
35 |
|
sl@0
|
36 |
const TInt KInsertRecCnt = 1000;
|
sl@0
|
37 |
const TInt KUpdateRecCnt = KInsertRecCnt / 10;
|
sl@0
|
38 |
const TInt KDeleteRecCnt = KInsertRecCnt / 10;
|
sl@0
|
39 |
const TInt KSelectRecCnt = KInsertRecCnt / 10;
|
sl@0
|
40 |
|
sl@0
|
41 |
static TInt TheUpdateRecIds[KUpdateRecCnt] = {0};
|
sl@0
|
42 |
static TInt TheDeleteRecIds[KDeleteRecCnt] = {0};
|
sl@0
|
43 |
static TInt TheSelectRecIds[KSelectRecCnt] = {0};
|
sl@0
|
44 |
|
sl@0
|
45 |
static TInt TheInsertRecId = 0;
|
sl@0
|
46 |
static TInt TheUpdateRecId = 0;
|
sl@0
|
47 |
static TInt TheDeleteRecId = 0;
|
sl@0
|
48 |
static TInt TheSelectRecId = 0;
|
sl@0
|
49 |
|
sl@0
|
50 |
const char KMultiInsertSql[] = "INSERT INTO Tbl VALUES(:Id, 9234567890, 99.998, 'TEXT VALUE', x'AABBCCDDEEFF')";
|
sl@0
|
51 |
const char KMultiUpdateSql[] = "UPDATE Tbl SET D=11.113 WHERE I IN";
|
sl@0
|
52 |
const char KMultiDeleteSql[] = "DELETE FROM Tbl WHERE I IN";
|
sl@0
|
53 |
const char KMultiSelectSql[] = "SELECT I64,D,T,B FROM Tbl WHERE I IN";
|
sl@0
|
54 |
|
sl@0
|
55 |
const char KSingleInsertSql[] = "INSERT INTO Tbl VALUES(%d, 9234567890, 99.998, 'TEXT VALUE', x'AABBCCDDEEFF')";
|
sl@0
|
56 |
const char KSingleUpdateSql[] = "UPDATE Tbl SET D=11.113 WHERE I=";
|
sl@0
|
57 |
const char KSingleDeleteSql[] = "DELETE FROM Tbl WHERE I=";
|
sl@0
|
58 |
const char KSingleSelectSql[] = "SELECT I64,D,T,B FROM Tbl WHERE I=";
|
sl@0
|
59 |
|
sl@0
|
60 |
//This buffer is used for SQL statement formatting. 2000 bytes should be enough as a buffer max length.
|
sl@0
|
61 |
static TBuf8<2000> TheSqlBuf;
|
sl@0
|
62 |
//This buffer is used for printf related formatting. 500 characters should be enough.
|
sl@0
|
63 |
static TBuf<500> ThePrintBuf;
|
sl@0
|
64 |
|
sl@0
|
65 |
#define UNUSED_VAR(a) (a) = (a)
|
sl@0
|
66 |
#define UNUSED_PTR(a) a.Set(a)
|
sl@0
|
67 |
|
sl@0
|
68 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
69 |
|
sl@0
|
70 |
extern "C" const char* TestDbName(void)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
return (const char*)KTestDbName8().Ptr();
|
sl@0
|
73 |
}
|
sl@0
|
74 |
|
sl@0
|
75 |
static void DeleteTestFiles()
|
sl@0
|
76 |
{
|
sl@0
|
77 |
TheDb.Close();
|
sl@0
|
78 |
(void)RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
82 |
//Test macros and functions
|
sl@0
|
83 |
static void Check(TInt aValue, TInt aLine)
|
sl@0
|
84 |
{
|
sl@0
|
85 |
if(!aValue)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
DeleteTestFiles();
|
sl@0
|
88 |
TestTestLine(EFalse, aLine);
|
sl@0
|
89 |
}
|
sl@0
|
90 |
}
|
sl@0
|
91 |
static void Check(TInt aValue, TInt aExpected, TInt aLine)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
if(aValue != aExpected)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
DeleteTestFiles();
|
sl@0
|
96 |
RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
|
sl@0
|
97 |
TestTestLine(EFalse, aLine);
|
sl@0
|
98 |
}
|
sl@0
|
99 |
}
|
sl@0
|
100 |
#define TEST(arg) ::Check((arg), __LINE__)
|
sl@0
|
101 |
#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
|
sl@0
|
102 |
|
sl@0
|
103 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
104 |
|
sl@0
|
105 |
static TInt KillProcess(const TDesC& aProcessName)
|
sl@0
|
106 |
{
|
sl@0
|
107 |
TFullName name;
|
sl@0
|
108 |
//RDebug::Print(_L("Find and kill \"%S\" process.\n"), &aProcessName);
|
sl@0
|
109 |
TBuf<64> pattern(aProcessName);
|
sl@0
|
110 |
TInt length = pattern.Length();
|
sl@0
|
111 |
pattern += _L("*");
|
sl@0
|
112 |
TFindProcess procFinder(pattern);
|
sl@0
|
113 |
|
sl@0
|
114 |
while (procFinder.Next(name) == KErrNone)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
if (name.Length() > length)
|
sl@0
|
117 |
{//If found name is a string containing aProcessName string.
|
sl@0
|
118 |
TChar c(name[length]);
|
sl@0
|
119 |
if (c.IsAlphaDigit() ||
|
sl@0
|
120 |
c == TChar('_') ||
|
sl@0
|
121 |
c == TChar('-'))
|
sl@0
|
122 |
{
|
sl@0
|
123 |
// If the found name is other valid application name
|
sl@0
|
124 |
// starting with aProcessName string.
|
sl@0
|
125 |
//RDebug::Print(_L(":: Process name: \"%S\".\n"), &name);
|
sl@0
|
126 |
continue;
|
sl@0
|
127 |
}
|
sl@0
|
128 |
}
|
sl@0
|
129 |
RProcess proc;
|
sl@0
|
130 |
if (proc.Open(name) == KErrNone)
|
sl@0
|
131 |
{
|
sl@0
|
132 |
proc.Kill(0);
|
sl@0
|
133 |
//RDebug::Print(_L("\"%S\" process killed.\n"), &name);
|
sl@0
|
134 |
}
|
sl@0
|
135 |
proc.Close();
|
sl@0
|
136 |
}
|
sl@0
|
137 |
return KErrNone;
|
sl@0
|
138 |
}
|
sl@0
|
139 |
|
sl@0
|
140 |
static TInt TheCounterFreq = -10000000;
|
sl@0
|
141 |
const TInt KMicroSecIn1Sec = 1000000;
|
sl@0
|
142 |
|
sl@0
|
143 |
//Prints aFastCount parameter (converted to us)
|
sl@0
|
144 |
static TInt FcDiff2Us(TUint32 aFastCount)
|
sl@0
|
145 |
{
|
sl@0
|
146 |
double v = ((double)aFastCount * KMicroSecIn1Sec) / (double)TheCounterFreq;
|
sl@0
|
147 |
TInt v2 = (TInt)v;
|
sl@0
|
148 |
return v2;
|
sl@0
|
149 |
}
|
sl@0
|
150 |
|
sl@0
|
151 |
static void GetFastCounterFrequency()
|
sl@0
|
152 |
{
|
sl@0
|
153 |
TEST2(HAL::Get(HAL::EFastCounterFrequency, TheCounterFreq), KErrNone);
|
sl@0
|
154 |
TBuf8<32> printString;
|
sl@0
|
155 |
printString.Format(_L8("Counter frequency=%d\r\n"), TheCounterFreq);
|
sl@0
|
156 |
TestPrintf((const char*)printString.PtrZ());
|
sl@0
|
157 |
}
|
sl@0
|
158 |
|
sl@0
|
159 |
extern "C" unsigned int FastCounterValue(void)
|
sl@0
|
160 |
{
|
sl@0
|
161 |
return User::FastCounter();
|
sl@0
|
162 |
}
|
sl@0
|
163 |
|
sl@0
|
164 |
//The performance test case results are stored in the ThePerfTestResult array.
|
sl@0
|
165 |
static TUint32 ThePerfTestResult[EPerfTestModeCnt][EPerfTestTypeCnt];
|
sl@0
|
166 |
|
sl@0
|
167 |
extern "C" void StorePerfTestResult(TPerfTestMode aMode, TPerfTestType aType, unsigned int aResult)
|
sl@0
|
168 |
{
|
sl@0
|
169 |
ThePerfTestResult[aMode][aType] = aResult;
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
static void PrintPerfTestResults()
|
sl@0
|
173 |
{
|
sl@0
|
174 |
TBuf8<256> printString;
|
sl@0
|
175 |
TInt r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode] [EPerfTestMultiInsert]);
|
sl@0
|
176 |
TInt r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode] [EPerfTestMultiInsert]);
|
sl@0
|
177 |
TInt r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestMultiInsert]);
|
sl@0
|
178 |
TInt r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
|
sl@0
|
179 |
TInt r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
|
sl@0
|
180 |
TestPrintf("### SQL SQLITE-SQL SQLITE-DEFAULT\r\n");
|
sl@0
|
181 |
printString.Format(_L8("###Multi Insert: %8dus %8dus %8dus %8d%%%% %8d%%%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
|
sl@0
|
182 |
TestPrintf((const char*)printString.PtrZ());
|
sl@0
|
183 |
|
sl@0
|
184 |
r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode] [EPerfTestMultiUpdate]);
|
sl@0
|
185 |
r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode] [EPerfTestMultiUpdate]);
|
sl@0
|
186 |
r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestMultiUpdate]);
|
sl@0
|
187 |
r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
|
sl@0
|
188 |
r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
|
sl@0
|
189 |
printString.Format(_L8("###Multi Update: %8dus %8dus %8dus %8d%%%% %8d%%%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
|
sl@0
|
190 |
TestPrintf((const char*)printString.PtrZ());
|
sl@0
|
191 |
|
sl@0
|
192 |
r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode] [EPerfTestMultiDelete]);
|
sl@0
|
193 |
r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode] [EPerfTestMultiDelete]);
|
sl@0
|
194 |
r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestMultiDelete]);
|
sl@0
|
195 |
r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
|
sl@0
|
196 |
r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
|
sl@0
|
197 |
printString.Format(_L8("###Multi Delete: %8dus %8dus %8dus %8d%%%% %8d%%%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
|
sl@0
|
198 |
TestPrintf((const char*)printString.PtrZ());
|
sl@0
|
199 |
|
sl@0
|
200 |
r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode] [EPerfTestMultiSelect]);
|
sl@0
|
201 |
r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode] [EPerfTestMultiSelect]);
|
sl@0
|
202 |
r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestMultiSelect]);
|
sl@0
|
203 |
r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
|
sl@0
|
204 |
r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
|
sl@0
|
205 |
printString.Format(_L8("###Multi Select: %8dus %8dus %8dus %8d%%%% %8d%%%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
|
sl@0
|
206 |
TestPrintf((const char*)printString.PtrZ());
|
sl@0
|
207 |
|
sl@0
|
208 |
r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode] [EPerfTestSingleInsert]);
|
sl@0
|
209 |
r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode] [EPerfTestSingleInsert]);
|
sl@0
|
210 |
r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestSingleInsert]);
|
sl@0
|
211 |
r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
|
sl@0
|
212 |
r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
|
sl@0
|
213 |
printString.Format(_L8("##Single Insert: %8dus %8dus %8dus %8d%%%% %8d%%%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
|
sl@0
|
214 |
TestPrintf((const char*)printString.PtrZ());
|
sl@0
|
215 |
|
sl@0
|
216 |
r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode] [EPerfTestSingleUpdate]);
|
sl@0
|
217 |
r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode] [EPerfTestSingleUpdate]);
|
sl@0
|
218 |
r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestSingleUpdate]);
|
sl@0
|
219 |
r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
|
sl@0
|
220 |
r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
|
sl@0
|
221 |
printString.Format(_L8("##Single Update: %8dus %8dus %8dus %8d%%%% %8d%%%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
|
sl@0
|
222 |
TestPrintf((const char*)printString.PtrZ());
|
sl@0
|
223 |
|
sl@0
|
224 |
r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode] [EPerfTestSingleDelete]);
|
sl@0
|
225 |
r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode] [EPerfTestSingleDelete]);
|
sl@0
|
226 |
r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestSingleDelete]);
|
sl@0
|
227 |
r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
|
sl@0
|
228 |
r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
|
sl@0
|
229 |
printString.Format(_L8("##Single Delete: %8dus %8dus %8dus %8d%%%% %8d%%%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
|
sl@0
|
230 |
TestPrintf((const char*)printString.PtrZ());
|
sl@0
|
231 |
|
sl@0
|
232 |
r1 = FcDiff2Us(ThePerfTestResult[EPerfTestSqlMode] [EPerfTestSingleSelect]);
|
sl@0
|
233 |
r2 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteSqlMode] [EPerfTestSingleSelect]);
|
sl@0
|
234 |
r3 = FcDiff2Us(ThePerfTestResult[EPerfTestSqliteDefaultMode][EPerfTestSingleSelect]);
|
sl@0
|
235 |
r4 = (TInt)((Abs(r2 - r1) * 100.0) / r1);
|
sl@0
|
236 |
r5 = (TInt)((Abs(r3 - r1) * 100.0) / r1);
|
sl@0
|
237 |
printString.Format(_L8("##Single Select: %8dus %8dus %8dus %8d%%%% %8d%%%%\r\n"), r1, r2, r3, r2 > r1 ? -r4 : +r4, r3 > r1 ? -r5 : +r5);
|
sl@0
|
238 |
TestPrintf((const char*)printString.PtrZ());
|
sl@0
|
239 |
}
|
sl@0
|
240 |
|
sl@0
|
241 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
242 |
|
sl@0
|
243 |
static void CreateTestDir()
|
sl@0
|
244 |
{
|
sl@0
|
245 |
RFs fs;
|
sl@0
|
246 |
TInt err = fs.Connect();
|
sl@0
|
247 |
TEST2(err, KErrNone);
|
sl@0
|
248 |
|
sl@0
|
249 |
err = fs.MkDir(KTestDir);
|
sl@0
|
250 |
TEST(err == KErrNone || err == KErrAlreadyExists);
|
sl@0
|
251 |
|
sl@0
|
252 |
err = fs.CreatePrivatePath(EDriveC);
|
sl@0
|
253 |
TEST(err == KErrNone || err == KErrAlreadyExists);
|
sl@0
|
254 |
|
sl@0
|
255 |
fs.Close();
|
sl@0
|
256 |
}
|
sl@0
|
257 |
|
sl@0
|
258 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
259 |
|
sl@0
|
260 |
static void CreateTestDatabase()
|
sl@0
|
261 |
{
|
sl@0
|
262 |
RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
263 |
|
sl@0
|
264 |
_LIT8(KConfigStr, "encoding=\"UTF-8\"");
|
sl@0
|
265 |
TInt err = TheDb.Create(KTestDbName, &KConfigStr);
|
sl@0
|
266 |
TEST2(err, KErrNone);
|
sl@0
|
267 |
|
sl@0
|
268 |
err = TheDb.Exec(_L8("CREATE TABLE Tbl(I INTEGER PRIMARY KEY, I64 BIGINT, D DOUBLE, T TEXT, B BINARY)"));
|
sl@0
|
269 |
TEST2(err, 1);
|
sl@0
|
270 |
|
sl@0
|
271 |
TheDb.Close();
|
sl@0
|
272 |
}
|
sl@0
|
273 |
|
sl@0
|
274 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
275 |
//////////////////// SQL server tests ///////////////////////////
|
sl@0
|
276 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
277 |
|
sl@0
|
278 |
/**
|
sl@0
|
279 |
@SYMTestCaseID SYSLIB-SQLITE3-UT-4010
|
sl@0
|
280 |
@SYMTestCaseDesc SQL server multi-insert performance test.
|
sl@0
|
281 |
The test inserts 1000 records in a single transaction and stores
|
sl@0
|
282 |
the execution time for later use (comparison and printing).
|
sl@0
|
283 |
@SYMTestPriority High
|
sl@0
|
284 |
@SYMTestActions SQL server multi-insert performance test.
|
sl@0
|
285 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
286 |
@SYMREQ REQ8782
|
sl@0
|
287 |
*/
|
sl@0
|
288 |
static void SqlServerMultiInsertTest(const char aInsertSql[], TInt aInsertRecCnt)
|
sl@0
|
289 |
{
|
sl@0
|
290 |
TestNext(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4010 ");
|
sl@0
|
291 |
(void)KillProcess(KSqlSrvName);
|
sl@0
|
292 |
|
sl@0
|
293 |
TInt err = TheDb.Open(KTestDbName);
|
sl@0
|
294 |
TEST2(err, KErrNone);
|
sl@0
|
295 |
|
sl@0
|
296 |
RSqlStatement stmt;
|
sl@0
|
297 |
err = stmt.Prepare(TheDb, TPtrC8((const TUint8*)aInsertSql));
|
sl@0
|
298 |
TEST2(err, KErrNone);
|
sl@0
|
299 |
|
sl@0
|
300 |
TUint32 fc = FastCounterValue();
|
sl@0
|
301 |
err = TheDb.Exec(_L8("BEGIN"));
|
sl@0
|
302 |
TEST(err >= 0);
|
sl@0
|
303 |
|
sl@0
|
304 |
for(TInt i=0;i<aInsertRecCnt;++i)
|
sl@0
|
305 |
{
|
sl@0
|
306 |
err = stmt.BindInt(0, i + 1);
|
sl@0
|
307 |
TEST2(err, KErrNone);
|
sl@0
|
308 |
err = stmt.Exec();
|
sl@0
|
309 |
TEST2(err, 1);
|
sl@0
|
310 |
err = stmt.Reset();
|
sl@0
|
311 |
TEST2(err, KErrNone);
|
sl@0
|
312 |
}
|
sl@0
|
313 |
|
sl@0
|
314 |
err = TheDb.Exec(_L8("COMMIT"));
|
sl@0
|
315 |
TEST(err >= 0);
|
sl@0
|
316 |
StorePerfTestResult(EPerfTestSqlMode, EPerfTestMultiInsert, FastCounterValue() - fc);
|
sl@0
|
317 |
|
sl@0
|
318 |
stmt.Close();
|
sl@0
|
319 |
TheDb.Close();
|
sl@0
|
320 |
}
|
sl@0
|
321 |
|
sl@0
|
322 |
static void FormatSqlStmt(TDes8& aSqlBuf, const char aSql[], TInt aRecIds[], TInt aRecCnt)
|
sl@0
|
323 |
{
|
sl@0
|
324 |
aSqlBuf.Copy(TPtrC8((const TUint8*)aSql));
|
sl@0
|
325 |
aSqlBuf.Append(_L8("("));
|
sl@0
|
326 |
for(TInt i=0;i<aRecCnt;++i)
|
sl@0
|
327 |
{
|
sl@0
|
328 |
aSqlBuf.AppendNum((TInt64)aRecIds[i]);
|
sl@0
|
329 |
aSqlBuf.Append(_L8(","));
|
sl@0
|
330 |
}
|
sl@0
|
331 |
aSqlBuf.SetLength(aSqlBuf.Length() - 1);
|
sl@0
|
332 |
aSqlBuf.Append(_L8(")"));
|
sl@0
|
333 |
}
|
sl@0
|
334 |
|
sl@0
|
335 |
/**
|
sl@0
|
336 |
@SYMTestCaseID SYSLIB-SQLITE3-UT-4011
|
sl@0
|
337 |
@SYMTestCaseDesc SQL server multi-update performance test.
|
sl@0
|
338 |
The test updates 100 randomly chosen records and stores
|
sl@0
|
339 |
the execution time for later use (comparison and printing).
|
sl@0
|
340 |
@SYMTestPriority High
|
sl@0
|
341 |
@SYMTestActions SQL server multi-update performance test.
|
sl@0
|
342 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
343 |
@SYMREQ REQ8782
|
sl@0
|
344 |
*/
|
sl@0
|
345 |
static void SqlServerMultiUpdateTest(const char aUpdateSql[], TInt aUpdateRecIds[], TInt aUpdateRecCnt)
|
sl@0
|
346 |
{
|
sl@0
|
347 |
TestNext(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4011 ");
|
sl@0
|
348 |
(void)KillProcess(KSqlSrvName);
|
sl@0
|
349 |
|
sl@0
|
350 |
TInt err = TheDb.Open(KTestDbName);
|
sl@0
|
351 |
TEST2(err, KErrNone);
|
sl@0
|
352 |
|
sl@0
|
353 |
FormatSqlStmt(TheSqlBuf, aUpdateSql, aUpdateRecIds, aUpdateRecCnt);
|
sl@0
|
354 |
|
sl@0
|
355 |
TUint32 fc = FastCounterValue();
|
sl@0
|
356 |
err = TheDb.Exec(TheSqlBuf);
|
sl@0
|
357 |
StorePerfTestResult(EPerfTestSqlMode, EPerfTestMultiUpdate, FastCounterValue() - fc);
|
sl@0
|
358 |
TEST2(err, aUpdateRecCnt);
|
sl@0
|
359 |
|
sl@0
|
360 |
TheDb.Close();
|
sl@0
|
361 |
}
|
sl@0
|
362 |
|
sl@0
|
363 |
/**
|
sl@0
|
364 |
@SYMTestCaseID SYSLIB-SQLITE3-UT-4012
|
sl@0
|
365 |
@SYMTestCaseDesc SQL server multi-delete performance test.
|
sl@0
|
366 |
The test deletes 100 randomly chosen records and stores
|
sl@0
|
367 |
the execution time for later use (comparison and printing).
|
sl@0
|
368 |
@SYMTestPriority High
|
sl@0
|
369 |
@SYMTestActions SQL server multi-delete performance test.
|
sl@0
|
370 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
371 |
@SYMREQ REQ8782
|
sl@0
|
372 |
*/
|
sl@0
|
373 |
static void SqlServerMultiDeleteTest(const char aDeleteSql[], TInt aDeleteRecIds[], TInt aDeleteRecCnt)
|
sl@0
|
374 |
{
|
sl@0
|
375 |
TestNext(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4012 ");
|
sl@0
|
376 |
(void)KillProcess(KSqlSrvName);
|
sl@0
|
377 |
|
sl@0
|
378 |
TInt err = TheDb.Open(KTestDbName);
|
sl@0
|
379 |
TEST2(err, KErrNone);
|
sl@0
|
380 |
|
sl@0
|
381 |
FormatSqlStmt(TheSqlBuf, aDeleteSql, aDeleteRecIds, aDeleteRecCnt);
|
sl@0
|
382 |
|
sl@0
|
383 |
TUint32 fc = FastCounterValue();
|
sl@0
|
384 |
err = TheDb.Exec(TheSqlBuf);
|
sl@0
|
385 |
StorePerfTestResult(EPerfTestSqlMode, EPerfTestMultiDelete, FastCounterValue() - fc);
|
sl@0
|
386 |
TEST2(err, aDeleteRecCnt);
|
sl@0
|
387 |
|
sl@0
|
388 |
TheDb.Close();
|
sl@0
|
389 |
}
|
sl@0
|
390 |
|
sl@0
|
391 |
/**
|
sl@0
|
392 |
@SYMTestCaseID SYSLIB-SQLITE3-UT-4013
|
sl@0
|
393 |
@SYMTestCaseDesc SQL server multi-select performance test.
|
sl@0
|
394 |
The test selects 100 randomly chosen records and stores
|
sl@0
|
395 |
the execution time for later use (comparison and printing).
|
sl@0
|
396 |
@SYMTestPriority High
|
sl@0
|
397 |
@SYMTestActions SQL server multi-select performance test.
|
sl@0
|
398 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
399 |
@SYMREQ REQ8782
|
sl@0
|
400 |
*/
|
sl@0
|
401 |
static void SqlServerMultiSelectTest(const char aSelectSql[], TInt aSelectRecIds[], TInt aSelectRecCnt)
|
sl@0
|
402 |
{
|
sl@0
|
403 |
TestNext(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4013 ");
|
sl@0
|
404 |
(void)KillProcess(KSqlSrvName);
|
sl@0
|
405 |
|
sl@0
|
406 |
TInt err = TheDb.Open(KTestDbName);
|
sl@0
|
407 |
TEST2(err, KErrNone);
|
sl@0
|
408 |
|
sl@0
|
409 |
FormatSqlStmt(TheSqlBuf, aSelectSql, aSelectRecIds, aSelectRecCnt);
|
sl@0
|
410 |
|
sl@0
|
411 |
RSqlStatement stmt;
|
sl@0
|
412 |
err = stmt.Prepare(TheDb, TheSqlBuf);
|
sl@0
|
413 |
TEST2(err, KErrNone);
|
sl@0
|
414 |
TInt recCnt = 0;
|
sl@0
|
415 |
TUint32 fc = FastCounterValue();
|
sl@0
|
416 |
while((err = stmt.Next()) == KSqlAtRow)
|
sl@0
|
417 |
{
|
sl@0
|
418 |
TInt64 i64 = stmt.ColumnInt64(0);
|
sl@0
|
419 |
UNUSED_VAR(i64);
|
sl@0
|
420 |
TReal d = stmt.ColumnReal(1);
|
sl@0
|
421 |
UNUSED_VAR(d);
|
sl@0
|
422 |
TPtrC t;
|
sl@0
|
423 |
err = stmt.ColumnText(2, t);
|
sl@0
|
424 |
TEST2(err, KErrNone);
|
sl@0
|
425 |
UNUSED_PTR(t);
|
sl@0
|
426 |
TPtrC8 b;
|
sl@0
|
427 |
err = stmt.ColumnBinary(3, b);
|
sl@0
|
428 |
TEST2(err, KErrNone);
|
sl@0
|
429 |
UNUSED_PTR(b);
|
sl@0
|
430 |
++recCnt;
|
sl@0
|
431 |
}
|
sl@0
|
432 |
StorePerfTestResult(EPerfTestSqlMode, EPerfTestMultiSelect, FastCounterValue() - fc);
|
sl@0
|
433 |
TEST2(err, KSqlAtEnd);
|
sl@0
|
434 |
TEST2(recCnt, aSelectRecCnt);
|
sl@0
|
435 |
|
sl@0
|
436 |
stmt.Close();
|
sl@0
|
437 |
TheDb.Close();
|
sl@0
|
438 |
}
|
sl@0
|
439 |
|
sl@0
|
440 |
/**
|
sl@0
|
441 |
@SYMTestCaseID SYSLIB-SQLITE3-UT-4014
|
sl@0
|
442 |
@SYMTestCaseDesc SQL server single-insert performance test.
|
sl@0
|
443 |
The test inserts one record and stores
|
sl@0
|
444 |
the execution time for later use (comparison and printing).
|
sl@0
|
445 |
@SYMTestPriority High
|
sl@0
|
446 |
@SYMTestActions SQL server single-insert performance test.
|
sl@0
|
447 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
448 |
@SYMREQ REQ8782
|
sl@0
|
449 |
*/
|
sl@0
|
450 |
static void SqlServerSingleInsertTest(const char aSingleInsertSql[], TInt aInsertRecId)
|
sl@0
|
451 |
{
|
sl@0
|
452 |
TestNext(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4014 ");
|
sl@0
|
453 |
(void)KillProcess(KSqlSrvName);
|
sl@0
|
454 |
|
sl@0
|
455 |
TInt err = TheDb.Open(KTestDbName);
|
sl@0
|
456 |
TEST2(err, KErrNone);
|
sl@0
|
457 |
|
sl@0
|
458 |
TheSqlBuf.Format(TPtrC8((const TUint8*)aSingleInsertSql), aInsertRecId);
|
sl@0
|
459 |
TUint32 fc = FastCounterValue();
|
sl@0
|
460 |
err = TheDb.Exec(TheSqlBuf);
|
sl@0
|
461 |
StorePerfTestResult(EPerfTestSqlMode, EPerfTestSingleInsert, FastCounterValue() - fc);
|
sl@0
|
462 |
TEST2(err, 1);
|
sl@0
|
463 |
|
sl@0
|
464 |
TheDb.Close();
|
sl@0
|
465 |
}
|
sl@0
|
466 |
|
sl@0
|
467 |
/**
|
sl@0
|
468 |
@SYMTestCaseID SYSLIB-SQLITE3-UT-4015
|
sl@0
|
469 |
@SYMTestCaseDesc SQL server single-update performance test.
|
sl@0
|
470 |
The test updates one randomly chosen record and stores
|
sl@0
|
471 |
the execution time for later use (comparison and printing).
|
sl@0
|
472 |
@SYMTestPriority High
|
sl@0
|
473 |
@SYMTestActions SQL server single-update performance test.
|
sl@0
|
474 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
475 |
@SYMREQ REQ8782
|
sl@0
|
476 |
*/
|
sl@0
|
477 |
static void SqlServerSingleUpdateTest(const char aSingleUpdateSql[], TInt aUpdateRecId)
|
sl@0
|
478 |
{
|
sl@0
|
479 |
TestNext(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4015 ");
|
sl@0
|
480 |
(void)KillProcess(KSqlSrvName);
|
sl@0
|
481 |
|
sl@0
|
482 |
TInt err = TheDb.Open(KTestDbName);
|
sl@0
|
483 |
TEST2(err, KErrNone);
|
sl@0
|
484 |
|
sl@0
|
485 |
TheSqlBuf.Copy(TPtrC8((const TUint8*)aSingleUpdateSql));
|
sl@0
|
486 |
TheSqlBuf.AppendNum((TInt64)aUpdateRecId);
|
sl@0
|
487 |
TUint32 fc = FastCounterValue();
|
sl@0
|
488 |
err = TheDb.Exec(TheSqlBuf);
|
sl@0
|
489 |
StorePerfTestResult(EPerfTestSqlMode, EPerfTestSingleUpdate, FastCounterValue() - fc);
|
sl@0
|
490 |
TEST2(err, 1);
|
sl@0
|
491 |
|
sl@0
|
492 |
TheDb.Close();
|
sl@0
|
493 |
}
|
sl@0
|
494 |
|
sl@0
|
495 |
/**
|
sl@0
|
496 |
@SYMTestCaseID SYSLIB-SQLITE3-UT-4016
|
sl@0
|
497 |
@SYMTestCaseDesc SQL server single-delete performance test.
|
sl@0
|
498 |
The test deletes one randomly chosen record and stores
|
sl@0
|
499 |
the execution time for later use (comparison and printing).
|
sl@0
|
500 |
@SYMTestPriority High
|
sl@0
|
501 |
@SYMTestActions SQL server single-delete performance test.
|
sl@0
|
502 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
503 |
@SYMREQ REQ8782
|
sl@0
|
504 |
*/
|
sl@0
|
505 |
static void SqlServerSingleDeleteTest(const char aSingleDeleteSql[], TInt aDeleteRecId)
|
sl@0
|
506 |
{
|
sl@0
|
507 |
TestNext(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4016 ");
|
sl@0
|
508 |
(void)KillProcess(KSqlSrvName);
|
sl@0
|
509 |
|
sl@0
|
510 |
TInt err = TheDb.Open(KTestDbName);
|
sl@0
|
511 |
TEST2(err, KErrNone);
|
sl@0
|
512 |
|
sl@0
|
513 |
TheSqlBuf.Copy(TPtrC8((const TUint8*)aSingleDeleteSql));
|
sl@0
|
514 |
TheSqlBuf.AppendNum((TInt64)aDeleteRecId);
|
sl@0
|
515 |
TUint32 fc = FastCounterValue();
|
sl@0
|
516 |
err = TheDb.Exec(TheSqlBuf);
|
sl@0
|
517 |
StorePerfTestResult(EPerfTestSqlMode, EPerfTestSingleDelete, FastCounterValue() - fc);
|
sl@0
|
518 |
TEST2(err, 1);
|
sl@0
|
519 |
|
sl@0
|
520 |
TheDb.Close();
|
sl@0
|
521 |
}
|
sl@0
|
522 |
|
sl@0
|
523 |
/**
|
sl@0
|
524 |
@SYMTestCaseID SYSLIB-SQLITE3-UT-4017
|
sl@0
|
525 |
@SYMTestCaseDesc SQL server single-select performance test.
|
sl@0
|
526 |
The test selects one randomly chosen record and stores
|
sl@0
|
527 |
the execution time for later use (comparison and printing).
|
sl@0
|
528 |
@SYMTestPriority High
|
sl@0
|
529 |
@SYMTestActions SQL server single-select performance test.
|
sl@0
|
530 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
531 |
@SYMREQ REQ8782
|
sl@0
|
532 |
*/
|
sl@0
|
533 |
static void SqlServerSingleSelectTest(const char aSingleSelectSql[], TInt aSelectRecId)
|
sl@0
|
534 |
{
|
sl@0
|
535 |
TestNext(" @SYMTestCaseID:SYSLIB-SQLITE3-UT-4017 ");
|
sl@0
|
536 |
(void)KillProcess(KSqlSrvName);
|
sl@0
|
537 |
|
sl@0
|
538 |
TInt err = TheDb.Open(KTestDbName);
|
sl@0
|
539 |
TEST2(err, KErrNone);
|
sl@0
|
540 |
|
sl@0
|
541 |
TheSqlBuf.Copy(TPtrC8((const TUint8*)aSingleSelectSql));
|
sl@0
|
542 |
TheSqlBuf.AppendNum((TInt64)aSelectRecId);
|
sl@0
|
543 |
|
sl@0
|
544 |
RSqlStatement stmt;
|
sl@0
|
545 |
err = stmt.Prepare(TheDb, TheSqlBuf);
|
sl@0
|
546 |
TEST2(err, KErrNone);
|
sl@0
|
547 |
TInt recCnt = 0;
|
sl@0
|
548 |
TUint32 fc = FastCounterValue();
|
sl@0
|
549 |
while((err = stmt.Next()) == KSqlAtRow)
|
sl@0
|
550 |
{
|
sl@0
|
551 |
TInt64 i64 = stmt.ColumnInt64(0);
|
sl@0
|
552 |
UNUSED_VAR(i64);
|
sl@0
|
553 |
TReal d = stmt.ColumnReal(1);
|
sl@0
|
554 |
UNUSED_VAR(d);
|
sl@0
|
555 |
TPtrC t;
|
sl@0
|
556 |
err = stmt.ColumnText(2, t);
|
sl@0
|
557 |
TEST2(err, KErrNone);
|
sl@0
|
558 |
UNUSED_PTR(t);
|
sl@0
|
559 |
TPtrC8 b;
|
sl@0
|
560 |
err = stmt.ColumnBinary(3, b);
|
sl@0
|
561 |
TEST2(err, KErrNone);
|
sl@0
|
562 |
UNUSED_PTR(b);
|
sl@0
|
563 |
++recCnt;
|
sl@0
|
564 |
}
|
sl@0
|
565 |
StorePerfTestResult(EPerfTestSqlMode, EPerfTestSingleSelect, FastCounterValue() - fc);
|
sl@0
|
566 |
TEST2(err, KSqlAtEnd);
|
sl@0
|
567 |
TEST2(recCnt, 1);
|
sl@0
|
568 |
|
sl@0
|
569 |
stmt.Close();
|
sl@0
|
570 |
TheDb.Close();
|
sl@0
|
571 |
}
|
sl@0
|
572 |
|
sl@0
|
573 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
574 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
575 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
576 |
|
sl@0
|
577 |
static void DoSqlServerTests()
|
sl@0
|
578 |
{
|
sl@0
|
579 |
TestNext("SQL: Create the test database");
|
sl@0
|
580 |
CreateTestDatabase();
|
sl@0
|
581 |
|
sl@0
|
582 |
TBuf8<100> msgbuf;
|
sl@0
|
583 |
|
sl@0
|
584 |
msgbuf.Format(_L8("SQL: insert %d records in a single transaction"), KInsertRecCnt);
|
sl@0
|
585 |
TestNext((const char*)msgbuf.PtrZ());
|
sl@0
|
586 |
SqlServerMultiInsertTest(KMultiInsertSql, KInsertRecCnt);
|
sl@0
|
587 |
|
sl@0
|
588 |
msgbuf.Format(_L8("SQL: update %d records in a single transaction"), KUpdateRecCnt);
|
sl@0
|
589 |
TestNext((const char*)msgbuf.PtrZ());
|
sl@0
|
590 |
SqlServerMultiUpdateTest(KMultiUpdateSql, TheUpdateRecIds, KUpdateRecCnt);
|
sl@0
|
591 |
|
sl@0
|
592 |
msgbuf.Format(_L8("SQL: delete %d records in a single transaction"), KDeleteRecCnt);
|
sl@0
|
593 |
TestNext((const char*)msgbuf.PtrZ());
|
sl@0
|
594 |
SqlServerMultiDeleteTest(KMultiDeleteSql, TheDeleteRecIds, KDeleteRecCnt);
|
sl@0
|
595 |
|
sl@0
|
596 |
msgbuf.Format(_L8("SQL: select %d records"), KSelectRecCnt);
|
sl@0
|
597 |
msgbuf.Copy(msgbuf);
|
sl@0
|
598 |
TestNext((const char*)msgbuf.PtrZ());
|
sl@0
|
599 |
SqlServerMultiSelectTest(KMultiSelectSql, TheSelectRecIds, KSelectRecCnt);
|
sl@0
|
600 |
|
sl@0
|
601 |
TestNext("SQL: insert a single record");
|
sl@0
|
602 |
SqlServerSingleInsertTest(KSingleInsertSql, TheInsertRecId);
|
sl@0
|
603 |
|
sl@0
|
604 |
TestNext("SQL: update a single record");
|
sl@0
|
605 |
SqlServerSingleUpdateTest(KSingleUpdateSql, TheUpdateRecId);
|
sl@0
|
606 |
|
sl@0
|
607 |
TestNext("SQL: delete a single record");
|
sl@0
|
608 |
SqlServerSingleDeleteTest(KSingleDeleteSql, TheDeleteRecId);
|
sl@0
|
609 |
|
sl@0
|
610 |
TestNext("SQL: select a single record");
|
sl@0
|
611 |
SqlServerSingleSelectTest(KSingleSelectSql, TheSelectRecId);
|
sl@0
|
612 |
|
sl@0
|
613 |
(void)RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
614 |
}
|
sl@0
|
615 |
|
sl@0
|
616 |
static void DoSqliteLibraryTests(TPerfTestMode aPerfTestMode)
|
sl@0
|
617 |
{
|
sl@0
|
618 |
TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
|
sl@0
|
619 |
|
sl@0
|
620 |
SqliteInitialize(aPerfTestMode);
|
sl@0
|
621 |
|
sl@0
|
622 |
TestNext("SQLite: Create the test database");
|
sl@0
|
623 |
CreateTestDatabase();
|
sl@0
|
624 |
|
sl@0
|
625 |
TBuf8<200> msgbuf;
|
sl@0
|
626 |
_LIT8(KSqliteConfigSql, "\"SQL\"");
|
sl@0
|
627 |
_LIT8(KSqliteConfigDefault, "\"Default\"");
|
sl@0
|
628 |
|
sl@0
|
629 |
msgbuf.Format(_L8("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4018: SQLite, configuration: %S: insert %d records in a single transaction"),
|
sl@0
|
630 |
aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault, KInsertRecCnt);
|
sl@0
|
631 |
TestNext((const char*)msgbuf.PtrZ());
|
sl@0
|
632 |
SqliteMultiInsertTest(aPerfTestMode, KMultiInsertSql, KInsertRecCnt);
|
sl@0
|
633 |
|
sl@0
|
634 |
msgbuf.Format(_L8("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4019: SQLite, configuration: %S: update %d records in a single transaction"),
|
sl@0
|
635 |
aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault, KUpdateRecCnt);
|
sl@0
|
636 |
TestNext((const char*)msgbuf.PtrZ());
|
sl@0
|
637 |
SqliteMultiUpdateTest(aPerfTestMode, KMultiUpdateSql, TheUpdateRecIds, KUpdateRecCnt);
|
sl@0
|
638 |
|
sl@0
|
639 |
msgbuf.Format(_L8("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4020: SQLite, configuration: %S: delete %d records in a single transaction"),
|
sl@0
|
640 |
aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault, KDeleteRecCnt);
|
sl@0
|
641 |
TestNext((const char*)msgbuf.PtrZ());
|
sl@0
|
642 |
SqliteMultiDeleteTest(aPerfTestMode, KMultiDeleteSql, TheDeleteRecIds, KDeleteRecCnt);
|
sl@0
|
643 |
|
sl@0
|
644 |
msgbuf.Format(_L8("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4021: SQLite, configuration: %S: select %d records"),
|
sl@0
|
645 |
aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault, KSelectRecCnt);
|
sl@0
|
646 |
TestNext((const char*)msgbuf.PtrZ());
|
sl@0
|
647 |
SqliteMultiSelectTest(aPerfTestMode, KMultiSelectSql, TheSelectRecIds, KSelectRecCnt);
|
sl@0
|
648 |
|
sl@0
|
649 |
msgbuf.Format(_L8("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4022: SQLite, configuration: %S: insert a single record"),
|
sl@0
|
650 |
aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault);
|
sl@0
|
651 |
TestNext((const char*)msgbuf.PtrZ());
|
sl@0
|
652 |
SqliteSingleInsertTest(aPerfTestMode, KSingleInsertSql, TheInsertRecId);
|
sl@0
|
653 |
|
sl@0
|
654 |
msgbuf.Format(_L8("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4023: SQLite, configuration: %S: update a single record"),
|
sl@0
|
655 |
aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault);
|
sl@0
|
656 |
TestNext((const char*)msgbuf.PtrZ());
|
sl@0
|
657 |
SqliteSingleUpdateTest(aPerfTestMode, KSingleUpdateSql, TheUpdateRecId);
|
sl@0
|
658 |
|
sl@0
|
659 |
msgbuf.Format(_L8("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4024: SQLite, configuration: %S: delete a single record"),
|
sl@0
|
660 |
aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault);
|
sl@0
|
661 |
TestNext((const char*)msgbuf.PtrZ());
|
sl@0
|
662 |
SqliteSingleDeleteTest(aPerfTestMode, KSingleDeleteSql, TheDeleteRecId);
|
sl@0
|
663 |
|
sl@0
|
664 |
msgbuf.Format(_L8("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4025: SQLite, configuration: %S: select a single record"),
|
sl@0
|
665 |
aPerfTestMode == EPerfTestSqliteSqlMode ? &KSqliteConfigSql : &KSqliteConfigDefault);
|
sl@0
|
666 |
TestNext((const char*)msgbuf.PtrZ());
|
sl@0
|
667 |
SqliteSingleSelectTest(aPerfTestMode, KSingleSelectSql, TheSelectRecId);
|
sl@0
|
668 |
|
sl@0
|
669 |
(void)RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
670 |
|
sl@0
|
671 |
SqliteFinalize(aPerfTestMode);
|
sl@0
|
672 |
}
|
sl@0
|
673 |
|
sl@0
|
674 |
static TBool IdIn(TInt aId, const TInt aData[], TInt aDataSize)
|
sl@0
|
675 |
{
|
sl@0
|
676 |
TEST(aId > 0);
|
sl@0
|
677 |
TEST(aDataSize >= 0);
|
sl@0
|
678 |
for(TInt i=0;i<aDataSize;++i)
|
sl@0
|
679 |
{
|
sl@0
|
680 |
TEST(aData[i] > 0);
|
sl@0
|
681 |
if(aData[i] == aId)
|
sl@0
|
682 |
{
|
sl@0
|
683 |
return ETrue;
|
sl@0
|
684 |
}
|
sl@0
|
685 |
}
|
sl@0
|
686 |
return EFalse;
|
sl@0
|
687 |
}
|
sl@0
|
688 |
|
sl@0
|
689 |
static void VerifyGeneratedRecIds()
|
sl@0
|
690 |
{
|
sl@0
|
691 |
TInt i;
|
sl@0
|
692 |
|
sl@0
|
693 |
for(i=0;i<KUpdateRecCnt;++i)
|
sl@0
|
694 |
{
|
sl@0
|
695 |
TEST(TheUpdateRecIds[i] > 0 && TheUpdateRecIds[i] <= KInsertRecCnt);
|
sl@0
|
696 |
TEST(!IdIn(TheUpdateRecIds[i], TheUpdateRecIds, i));
|
sl@0
|
697 |
TEST(!IdIn(TheUpdateRecIds[i], TheDeleteRecIds, KDeleteRecCnt));
|
sl@0
|
698 |
TEST(!IdIn(TheUpdateRecIds[i], TheSelectRecIds, KSelectRecCnt));
|
sl@0
|
699 |
}
|
sl@0
|
700 |
|
sl@0
|
701 |
for(i=0;i<KDeleteRecCnt;++i)
|
sl@0
|
702 |
{
|
sl@0
|
703 |
TEST(TheDeleteRecIds[i] > 0 && TheDeleteRecIds[i] <= KInsertRecCnt);
|
sl@0
|
704 |
TEST(!IdIn(TheDeleteRecIds[i], TheDeleteRecIds, i));
|
sl@0
|
705 |
TEST(!IdIn(TheDeleteRecIds[i], TheUpdateRecIds, KUpdateRecCnt));
|
sl@0
|
706 |
TEST(!IdIn(TheDeleteRecIds[i], TheSelectRecIds, KSelectRecCnt));
|
sl@0
|
707 |
}
|
sl@0
|
708 |
|
sl@0
|
709 |
for(i=0;i<KSelectRecCnt;++i)
|
sl@0
|
710 |
{
|
sl@0
|
711 |
TEST(TheSelectRecIds[i] > 0 && TheSelectRecIds[i] <= KInsertRecCnt);
|
sl@0
|
712 |
TEST(!IdIn(TheSelectRecIds[i], TheSelectRecIds, i));
|
sl@0
|
713 |
TEST(!IdIn(TheSelectRecIds[i], TheUpdateRecIds, KUpdateRecCnt));
|
sl@0
|
714 |
TEST(!IdIn(TheSelectRecIds[i], TheDeleteRecIds, KDeleteRecCnt));
|
sl@0
|
715 |
}
|
sl@0
|
716 |
|
sl@0
|
717 |
TEST(TheInsertRecId > 0);
|
sl@0
|
718 |
|
sl@0
|
719 |
TEST(TheUpdateRecId > 0 && TheUpdateRecId <= KInsertRecCnt);
|
sl@0
|
720 |
TEST(!IdIn(TheUpdateRecId, TheUpdateRecIds, KUpdateRecCnt));
|
sl@0
|
721 |
TEST(!IdIn(TheUpdateRecId, TheDeleteRecIds, KDeleteRecCnt));
|
sl@0
|
722 |
TEST(!IdIn(TheUpdateRecId, TheSelectRecIds, KSelectRecCnt));
|
sl@0
|
723 |
|
sl@0
|
724 |
TEST(TheDeleteRecId > 0 && TheDeleteRecId <= KInsertRecCnt);
|
sl@0
|
725 |
TEST(!IdIn(TheDeleteRecId, TheUpdateRecIds, KUpdateRecCnt));
|
sl@0
|
726 |
TEST(!IdIn(TheDeleteRecId, TheDeleteRecIds, KDeleteRecCnt));
|
sl@0
|
727 |
TEST(!IdIn(TheDeleteRecId, TheSelectRecIds, KSelectRecCnt));
|
sl@0
|
728 |
|
sl@0
|
729 |
TEST(TheSelectRecId > 0 && TheSelectRecId <= KInsertRecCnt);
|
sl@0
|
730 |
TEST(!IdIn(TheSelectRecId, TheUpdateRecIds, KUpdateRecCnt));
|
sl@0
|
731 |
TEST(!IdIn(TheSelectRecId, TheDeleteRecIds, KDeleteRecCnt));
|
sl@0
|
732 |
TEST(!IdIn(TheSelectRecId, TheSelectRecIds, KSelectRecCnt));
|
sl@0
|
733 |
}
|
sl@0
|
734 |
|
sl@0
|
735 |
static void GenerateTestRecIds()
|
sl@0
|
736 |
{
|
sl@0
|
737 |
TTime now;
|
sl@0
|
738 |
now.UniversalTime();
|
sl@0
|
739 |
TInt64 seed = now.Int64();
|
sl@0
|
740 |
TInt i;
|
sl@0
|
741 |
|
sl@0
|
742 |
//Update multi
|
sl@0
|
743 |
for(i=0;i<KUpdateRecCnt;)
|
sl@0
|
744 |
{
|
sl@0
|
745 |
TInt id = Math::Rand(seed) % KInsertRecCnt;
|
sl@0
|
746 |
if(id > 0 && !IdIn(id, TheUpdateRecIds, i))
|
sl@0
|
747 |
{
|
sl@0
|
748 |
TheUpdateRecIds[i++] = id;
|
sl@0
|
749 |
}
|
sl@0
|
750 |
}
|
sl@0
|
751 |
//Delete multi
|
sl@0
|
752 |
for(i=0;i<KDeleteRecCnt;)
|
sl@0
|
753 |
{
|
sl@0
|
754 |
TInt id = Math::Rand(seed) % KInsertRecCnt;
|
sl@0
|
755 |
if(id > 0 && !IdIn(id, TheDeleteRecIds, i) && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt))
|
sl@0
|
756 |
{
|
sl@0
|
757 |
TheDeleteRecIds[i++] = id;
|
sl@0
|
758 |
}
|
sl@0
|
759 |
}
|
sl@0
|
760 |
//Select multi
|
sl@0
|
761 |
for(i=0;i<KSelectRecCnt;)
|
sl@0
|
762 |
{
|
sl@0
|
763 |
TInt id = Math::Rand(seed) % KInsertRecCnt;
|
sl@0
|
764 |
if(id > 0 && !IdIn(id, TheSelectRecIds, i) && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt) &&
|
sl@0
|
765 |
!IdIn(id, TheDeleteRecIds, KDeleteRecCnt))
|
sl@0
|
766 |
{
|
sl@0
|
767 |
TheSelectRecIds[i++] = id;
|
sl@0
|
768 |
}
|
sl@0
|
769 |
}
|
sl@0
|
770 |
//Insert one
|
sl@0
|
771 |
TheInsertRecId = KInsertRecCnt + 1;
|
sl@0
|
772 |
//Update one
|
sl@0
|
773 |
for(;;)
|
sl@0
|
774 |
{
|
sl@0
|
775 |
TInt id = Math::Rand(seed) % KInsertRecCnt;
|
sl@0
|
776 |
if(id > 0 && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt) && !IdIn(id, TheDeleteRecIds, KDeleteRecCnt) &&
|
sl@0
|
777 |
!IdIn(id, TheSelectRecIds, KSelectRecCnt))
|
sl@0
|
778 |
{
|
sl@0
|
779 |
TheUpdateRecId = id;
|
sl@0
|
780 |
break;
|
sl@0
|
781 |
}
|
sl@0
|
782 |
}
|
sl@0
|
783 |
//Delete one
|
sl@0
|
784 |
for(;;)
|
sl@0
|
785 |
{
|
sl@0
|
786 |
TInt id = Math::Rand(seed) % KInsertRecCnt;
|
sl@0
|
787 |
if(id > 0 && id != TheUpdateRecId && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt) &&
|
sl@0
|
788 |
!IdIn(id, TheDeleteRecIds, KDeleteRecCnt) && !IdIn(id, TheSelectRecIds, KSelectRecCnt))
|
sl@0
|
789 |
{
|
sl@0
|
790 |
TheDeleteRecId = id;
|
sl@0
|
791 |
break;
|
sl@0
|
792 |
}
|
sl@0
|
793 |
}
|
sl@0
|
794 |
//Select one
|
sl@0
|
795 |
for(;;)
|
sl@0
|
796 |
{
|
sl@0
|
797 |
TInt id = Math::Rand(seed) % KInsertRecCnt;
|
sl@0
|
798 |
if(id > 0 && id != TheUpdateRecId && id != TheDeleteRecId && !IdIn(id, TheUpdateRecIds, KUpdateRecCnt) &&
|
sl@0
|
799 |
!IdIn(id, TheDeleteRecIds, KDeleteRecCnt) &&
|
sl@0
|
800 |
!IdIn(id, TheSelectRecIds, KSelectRecCnt))
|
sl@0
|
801 |
{
|
sl@0
|
802 |
TheSelectRecId = id;
|
sl@0
|
803 |
break;
|
sl@0
|
804 |
}
|
sl@0
|
805 |
}
|
sl@0
|
806 |
}
|
sl@0
|
807 |
|
sl@0
|
808 |
static void DoTests()
|
sl@0
|
809 |
{
|
sl@0
|
810 |
TestStart("Get fast counter frequency");
|
sl@0
|
811 |
GetFastCounterFrequency();
|
sl@0
|
812 |
|
sl@0
|
813 |
TestNext("Generate test record ids");
|
sl@0
|
814 |
GenerateTestRecIds();
|
sl@0
|
815 |
|
sl@0
|
816 |
TestNext("Verify generated test record ids");
|
sl@0
|
817 |
VerifyGeneratedRecIds();
|
sl@0
|
818 |
|
sl@0
|
819 |
DoSqlServerTests();
|
sl@0
|
820 |
(void)KillProcess(KSqlSrvName);
|
sl@0
|
821 |
|
sl@0
|
822 |
DoSqliteLibraryTests(EPerfTestSqliteDefaultMode);
|
sl@0
|
823 |
|
sl@0
|
824 |
DoSqliteLibraryTests(EPerfTestSqliteSqlMode);
|
sl@0
|
825 |
|
sl@0
|
826 |
PrintPerfTestResults();
|
sl@0
|
827 |
}
|
sl@0
|
828 |
|
sl@0
|
829 |
TInt E32Main()
|
sl@0
|
830 |
{
|
sl@0
|
831 |
TestOpen(KTestName);
|
sl@0
|
832 |
TestTitle();
|
sl@0
|
833 |
|
sl@0
|
834 |
CTrapCleanup* tc = CTrapCleanup::New();
|
sl@0
|
835 |
|
sl@0
|
836 |
__UHEAP_MARK;
|
sl@0
|
837 |
|
sl@0
|
838 |
CreateTestDir();
|
sl@0
|
839 |
DeleteTestFiles();
|
sl@0
|
840 |
DoTests();
|
sl@0
|
841 |
DeleteTestFiles();
|
sl@0
|
842 |
|
sl@0
|
843 |
__UHEAP_MARKEND;
|
sl@0
|
844 |
|
sl@0
|
845 |
TestEnd();
|
sl@0
|
846 |
TestClose();
|
sl@0
|
847 |
|
sl@0
|
848 |
delete tc;
|
sl@0
|
849 |
|
sl@0
|
850 |
User::Heap().Check();
|
sl@0
|
851 |
return KErrNone;
|
sl@0
|
852 |
}
|