os/persistentdata/persistentstorage/sqlite3api/TEST/t_sqliteperfc.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/t_sqliteperfc.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,505 @@
     1.4 +/*
     1.5 +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +#include <stdio.h>
    1.24 +#include <stdlib.h>
    1.25 +#include <string.h>
    1.26 +#include <wchar.h>
    1.27 +#include <errno.h>
    1.28 +#include <sys/stat.h>
    1.29 +#include <unistd.h>
    1.30 +#include <sqlite3.h>
    1.31 +#include "t_sqliteperf.h"
    1.32 +
    1.33 +static sqlite3* TheDb2 = 0;
    1.34 +
    1.35 +static char TheSqlBuf2[2000];
    1.36 +
    1.37 +#define UNUSED_VAR(a) (a) = (a)
    1.38 +
    1.39 +/* ///////////////////////////////////////////////////////////////////////////////////// */
    1.40 +
    1.41 +static void TestCleanup()
    1.42 +	{
    1.43 +	if(TheDb2)
    1.44 +		{
    1.45 +		sqlite3_close(TheDb2);
    1.46 +		TheDb2 = 0;
    1.47 +		}
    1.48 +	(void)remove(TestDbName());
    1.49 +	}
    1.50 +
    1.51 +/* ///////////////////////////////////////////////////////////////////////////////////// */
    1.52 +/* Test macros and functions */
    1.53 +
    1.54 +static void Check1(int aValue, int aLine)
    1.55 +	{
    1.56 +	if(!aValue)
    1.57 +		{
    1.58 +		if(TheDb2)
    1.59 +			{
    1.60 +			const char* errmsg = sqlite3_errmsg(TheDb2);
    1.61 +			PrintS("*** SQLITE error message: %s\r\n", errmsg);
    1.62 +			}
    1.63 +		TestCleanup();
    1.64 +		PrintI("*** Test check failed! Line=%d\r\n", aLine);
    1.65 +		TestAbort(aLine);
    1.66 +		}
    1.67 +	}
    1.68 +static void Check2(int aValue, int aExpected, int aLine)
    1.69 +	{
    1.70 +	if(aValue != aExpected)
    1.71 +		{
    1.72 +		if(TheDb2)
    1.73 +			{
    1.74 +			const char* errmsg = sqlite3_errmsg(TheDb2);
    1.75 +			PrintS("*** SQLITE error message: %s\r\n", errmsg);
    1.76 +			}
    1.77 +		TestCleanup();
    1.78 +		PrintIII("*** Test check failed! Line=%d. Expected error: %d, got: %d\r\n", aLine, aExpected, aValue);
    1.79 +		TestAbort(aLine);
    1.80 +		}
    1.81 +	}
    1.82 +#define TEST(arg) Check1((arg), __LINE__)
    1.83 +#define TEST2(aValue, aExpected) Check2(aValue, aExpected, __LINE__)
    1.84 +
    1.85 +/* ///////////////////////////////////////////////////////////////////////////////////// */
    1.86 +
    1.87 +//"PRAGMA cache_size=1024" and "PRAGMA locking_mode=EXCLUSIVE" statements executed only if 
    1.88 +//aPerfTestMode is EPerfTestSqliteMode (to match the Symbian SQL build time settings of SQLite)
    1.89 +static void ExecSqliteConfig(TPerfTestMode aPerfTestMode)
    1.90 +	{
    1.91 +	TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
    1.92 +	if(aPerfTestMode == EPerfTestSqliteSqlMode)
    1.93 +		{
    1.94 +		int err;
    1.95 +		err = sqlite3_exec(TheDb2, "PRAGMA cache_size=1024", 0, 0, 0);
    1.96 +		TEST2(err, SQLITE_OK);
    1.97 +		err = sqlite3_exec(TheDb2, "PRAGMA locking_mode=EXCLUSIVE", 0, 0, 0);
    1.98 +		TEST2(err, SQLITE_OK);
    1.99 +		err = sqlite3_exec(TheDb2, "PRAGMA auto_vacuum=incremental", 0, 0, 0);
   1.100 +		TEST2(err, SQLITE_OK);
   1.101 +		err = sqlite3_exec(TheDb2, "PRAGMA journal_mode=PERSIST", 0, 0, 0);
   1.102 +		TEST2(err, SQLITE_OK);
   1.103 +		err = sqlite3_exec(TheDb2, "PRAGMA journal_size_limit=2048000", 0, 0, 0);
   1.104 +		TEST2(err, SQLITE_OK);
   1.105 +		}
   1.106 +	}
   1.107 +
   1.108 +/* ///////////////////////////////////////////////////////////////////////////////////// */
   1.109 +
   1.110 +/**
   1.111 +@SYMTestCaseID			SYSLIB-SQLITE3-UT-4018
   1.112 +@SYMTestCaseDesc		SQLite library multi-insert performance test.
   1.113 +						The test inserts 1000 records in a single transaction and stores 
   1.114 +						the execution time for later use (comparison and printing).
   1.115 +						The results of this test case will be compared against the results of
   1.116 +						the SYSLIB-SQLITE3-UT-4010 test case - "SQL server multi-insert performance test".
   1.117 +@SYMTestPriority		High
   1.118 +@SYMTestActions			SQLite library multi-insert performance test.
   1.119 +@SYMTestExpectedResults Test must not fail
   1.120 +@SYMREQ					REQ8782
   1.121 +*/
   1.122 +void SqliteMultiInsertTest(TPerfTestMode aPerfTestMode, const char aInsertSql[], int aInsertRecCnt)
   1.123 +	{
   1.124 +	int err;
   1.125 +	int i;
   1.126 +	const char* tail = 0;
   1.127 +	sqlite3_stmt* stmt = 0;
   1.128 +	unsigned int fc;
   1.129 +	
   1.130 +	TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
   1.131 +	TEST(!TheDb2);
   1.132 +	err = sqlite3_open(TestDbName(), &TheDb2);
   1.133 +	TEST2(err, SQLITE_OK);
   1.134 +	ExecSqliteConfig(aPerfTestMode);
   1.135 +
   1.136 +	err = sqlite3_prepare(TheDb2, aInsertSql, -1, &stmt, &tail);
   1.137 +	TEST2(err, SQLITE_OK);
   1.138 +	
   1.139 +	fc = FastCounterValue();
   1.140 +	err = sqlite3_exec(TheDb2, "BEGIN", 0, 0, 0);
   1.141 +	TEST2(err, SQLITE_OK);
   1.142 +
   1.143 +	for(i=0;i<aInsertRecCnt;++i)
   1.144 +		{
   1.145 +		err = sqlite3_bind_int(stmt, 1, i + 1);
   1.146 +		TEST2(err, SQLITE_OK);
   1.147 +
   1.148 +		err = sqlite3_step(stmt);
   1.149 +		TEST2(err, SQLITE_DONE);
   1.150 +		
   1.151 +		err = sqlite3_reset(stmt);		
   1.152 +		TEST2(err, SQLITE_OK);
   1.153 +		}
   1.154 +
   1.155 +	err = sqlite3_exec(TheDb2, "COMMIT", 0, 0, 0);
   1.156 +	TEST2(err, SQLITE_OK);
   1.157 +	StorePerfTestResult(aPerfTestMode, EPerfTestMultiInsert, FastCounterValue() - fc);
   1.158 +
   1.159 +	sqlite3_finalize(stmt);	
   1.160 +	sqlite3_close(TheDb2);
   1.161 +	TheDb2 = 0;
   1.162 +	}
   1.163 +
   1.164 +static void FormatSqlStmt(char* aSqlBuf, const char aSql[], int aRecIds[], int aRecCnt)
   1.165 +	{
   1.166 +	int i;
   1.167 +	strcpy(aSqlBuf, aSql);
   1.168 +	strcat(aSqlBuf, "(");
   1.169 +	for(i=0;i<aRecCnt;++i)
   1.170 +		{
   1.171 +		char tmp[10];
   1.172 +		sprintf(tmp, "%d", aRecIds[i]);
   1.173 +		strcat(aSqlBuf, tmp);
   1.174 +		strcat(aSqlBuf, ",");
   1.175 +		}
   1.176 +	aSqlBuf[strlen(aSqlBuf) - 1] = ')';
   1.177 +	}
   1.178 +
   1.179 +/**
   1.180 +@SYMTestCaseID			SYSLIB-SQLITE3-UT-4019
   1.181 +@SYMTestCaseDesc		SQLite library multi-update performance test.
   1.182 +						The test updates 100 records and stores 
   1.183 +						the execution time for later use (comparison and printing).
   1.184 +						The IDs of the updated records are exactly the same as the IDs of the updated
   1.185 +						records, used by SYSLIB-SQLITE3-UT-4011 test case.
   1.186 +						The results of this test case will be compared against the results of
   1.187 +						the SYSLIB-SQLITE3-UT-4011 test case - "SQL server multi-update performance test".
   1.188 +@SYMTestPriority		High
   1.189 +@SYMTestActions			SQLite library multi-update performance test.
   1.190 +@SYMTestExpectedResults Test must not fail
   1.191 +@SYMREQ					REQ8782
   1.192 +*/
   1.193 +void SqliteMultiUpdateTest(TPerfTestMode aPerfTestMode, const char aUpdateSql[], int aUpdateRecIds[], int aUpdateRecCnt)
   1.194 +	{
   1.195 +	int err;
   1.196 +	unsigned int fc;
   1.197 +	
   1.198 +	TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
   1.199 +	TEST(!TheDb2);
   1.200 +	err = sqlite3_open(TestDbName(), &TheDb2);
   1.201 +	TEST2(err, SQLITE_OK);
   1.202 +	ExecSqliteConfig(aPerfTestMode);
   1.203 +
   1.204 +	FormatSqlStmt(TheSqlBuf2, aUpdateSql, aUpdateRecIds, aUpdateRecCnt);
   1.205 +
   1.206 +	fc = FastCounterValue();
   1.207 +	err = sqlite3_exec(TheDb2, TheSqlBuf2, 0, 0, 0);
   1.208 +	StorePerfTestResult(aPerfTestMode, EPerfTestMultiUpdate, FastCounterValue() - fc);
   1.209 +	TEST2(err, SQLITE_OK);
   1.210 +	
   1.211 +	sqlite3_close(TheDb2);
   1.212 +	TheDb2 = 0;
   1.213 +	}
   1.214 +
   1.215 +/**
   1.216 +@SYMTestCaseID			SYSLIB-SQLITE3-UT-4020
   1.217 +@SYMTestCaseDesc		SQLite library multi-delete performance test.
   1.218 +						The test deletes 100 records and stores 
   1.219 +						the execution time for later use (comparison and printing).
   1.220 +						The IDs of the deleted records are exactly the same as the IDs of the deleted
   1.221 +						records, used by SYSLIB-SQLITE3-UT-4012 test case.
   1.222 +						The results of this test case will be compared against the results of
   1.223 +						the SYSLIB-SQLITE3-UT-4012 test case - "SQL server multi-delete performance test".
   1.224 +@SYMTestPriority		High
   1.225 +@SYMTestActions			SQLite library multi-delete performance test.
   1.226 +@SYMTestExpectedResults Test must not fail
   1.227 +@SYMREQ					REQ8782
   1.228 +*/
   1.229 +void SqliteMultiDeleteTest(TPerfTestMode aPerfTestMode, const char aDeleteSql[], int aDeleteRecIds[], int aDeleteRecCnt)
   1.230 +	{
   1.231 +	int err;
   1.232 +	unsigned int fc;
   1.233 +	
   1.234 +	TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
   1.235 +	TEST(!TheDb2);
   1.236 +	err = sqlite3_open(TestDbName(), &TheDb2);
   1.237 +	TEST2(err, SQLITE_OK);
   1.238 +	ExecSqliteConfig(aPerfTestMode);
   1.239 +
   1.240 +	FormatSqlStmt(TheSqlBuf2, aDeleteSql, aDeleteRecIds, aDeleteRecCnt);
   1.241 +
   1.242 +	fc = FastCounterValue();
   1.243 +	err = sqlite3_exec(TheDb2, TheSqlBuf2, 0, 0, 0);
   1.244 +	StorePerfTestResult(aPerfTestMode, EPerfTestMultiDelete, FastCounterValue() - fc);
   1.245 +	TEST2(err, SQLITE_OK);
   1.246 +	
   1.247 +	sqlite3_close(TheDb2);
   1.248 +	TheDb2 = 0;
   1.249 +	}
   1.250 +
   1.251 +/**
   1.252 +@SYMTestCaseID			SYSLIB-SQLITE3-UT-4021
   1.253 +@SYMTestCaseDesc		SQLite library multi-select performance test.
   1.254 +						The test selects 100 records and stores 
   1.255 +						the execution time for later use (comparison and printing).
   1.256 +						The IDs of the selected records are exactly the same as the IDs of the selected
   1.257 +						records, used by SYSLIB-SQLITE3-UT-4013 test case.
   1.258 +						The results of this test case will be compared against the results of
   1.259 +						the SYSLIB-SQLITE3-UT-4013 test case - "SQL server multi-select performance test".
   1.260 +@SYMTestPriority		High
   1.261 +@SYMTestActions			SQLite library multi-select performance test.
   1.262 +@SYMTestExpectedResults Test must not fail
   1.263 +@SYMREQ					REQ8782
   1.264 +*/
   1.265 +void SqliteMultiSelectTest(TPerfTestMode aPerfTestMode, const char aSelectSql[], int aSelectRecIds[], int aSelectRecCnt)
   1.266 +	{
   1.267 +	int err;
   1.268 +	const char* tail = 0;
   1.269 +	sqlite3_stmt* stmt = 0;
   1.270 +	int recCnt = 0;
   1.271 +	unsigned int fc;
   1.272 +	
   1.273 +	TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
   1.274 +	TEST(!TheDb2);
   1.275 +	err = sqlite3_open(TestDbName(), &TheDb2);
   1.276 +	TEST2(err, SQLITE_OK);
   1.277 +	ExecSqliteConfig(aPerfTestMode);
   1.278 +
   1.279 +	FormatSqlStmt(TheSqlBuf2, aSelectSql, aSelectRecIds, aSelectRecCnt);
   1.280 +
   1.281 +	err = sqlite3_prepare(TheDb2, TheSqlBuf2, -1, &stmt, &tail);
   1.282 +	TEST2(err, SQLITE_OK);
   1.283 +	
   1.284 +	fc = FastCounterValue();
   1.285 +	while((err = sqlite3_step(stmt)) == SQLITE_ROW)
   1.286 +		{
   1.287 +		__int64 i64;
   1.288 +		double d;
   1.289 +		const unsigned short* t;
   1.290 +		const unsigned char* b;
   1.291 +		
   1.292 +		i64 = sqlite3_column_int64(stmt, 0);
   1.293 +		UNUSED_VAR(i64);
   1.294 +		d = sqlite3_column_double(stmt, 1);
   1.295 +		UNUSED_VAR(d);
   1.296 +		t = (const unsigned short*)sqlite3_column_text16(stmt, 2);
   1.297 +		UNUSED_VAR(t);
   1.298 +		b = (const unsigned char*)sqlite3_column_blob(stmt, 3);
   1.299 +		UNUSED_VAR(b);
   1.300 +		++recCnt;
   1.301 +		}
   1.302 +	StorePerfTestResult(aPerfTestMode, EPerfTestMultiSelect, FastCounterValue() - fc);
   1.303 +	TEST2(err, SQLITE_DONE);
   1.304 +	TEST2(recCnt, aSelectRecCnt);
   1.305 +
   1.306 +	sqlite3_finalize(stmt);	
   1.307 +	sqlite3_close(TheDb2);
   1.308 +	TheDb2 = 0;
   1.309 +	}
   1.310 +
   1.311 +/**
   1.312 +@SYMTestCaseID			SYSLIB-SQLITE3-UT-4022
   1.313 +@SYMTestCaseDesc		SQLite library single-insert performance test.
   1.314 +						The test inserts one record and stores 
   1.315 +						the execution time for later use (comparison and printing).
   1.316 +						The ID of the inserted record is exactly the same as the ID of the inserted
   1.317 +						record, used by SYSLIB-SQLITE3-UT-4014 test case.
   1.318 +						The results of this test case will be compared against the results of
   1.319 +						the SYSLIB-SQLITE3-UT-4014 test case - "SQL server single-insert performance test".
   1.320 +@SYMTestPriority		High
   1.321 +@SYMTestActions			SQLite library single-insert performance test.
   1.322 +@SYMTestExpectedResults Test must not fail
   1.323 +@SYMREQ					REQ8782
   1.324 +*/
   1.325 +void SqliteSingleInsertTest(TPerfTestMode aPerfTestMode, const char aSingleInsertSql[], TInt aInsertRecId)
   1.326 +	{
   1.327 +	int err;
   1.328 +	unsigned int fc;
   1.329 +	
   1.330 +	TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
   1.331 +	TEST(!TheDb2);
   1.332 +	err = sqlite3_open(TestDbName(), &TheDb2);
   1.333 +	TEST2(err, SQLITE_OK);
   1.334 +	ExecSqliteConfig(aPerfTestMode);
   1.335 +
   1.336 +	sprintf(TheSqlBuf2, aSingleInsertSql, aInsertRecId);
   1.337 +	fc = FastCounterValue();
   1.338 +	err = sqlite3_exec(TheDb2, TheSqlBuf2, 0, 0, 0);
   1.339 +	StorePerfTestResult(aPerfTestMode, EPerfTestSingleInsert, FastCounterValue() - fc);
   1.340 +	TEST2(err, SQLITE_OK);
   1.341 +	
   1.342 +	sqlite3_close(TheDb2);
   1.343 +	TheDb2 = 0;
   1.344 +	}
   1.345 +
   1.346 +/**
   1.347 +@SYMTestCaseID			SYSLIB-SQLITE3-UT-4023
   1.348 +@SYMTestCaseDesc		SQLite library single-update performance test.
   1.349 +						The test updates one record and stores 
   1.350 +						the execution time for later use (comparison and printing).
   1.351 +						The ID of the updated record is exactly the same as the ID of the updated
   1.352 +						record, used by SYSLIB-SQLITE3-UT-4015 test case.
   1.353 +						The results of this test case will be compared against the results of
   1.354 +						the SYSLIB-SQLITE3-UT-4015 test case - "SQL server single-update performance test".
   1.355 +@SYMTestPriority		High
   1.356 +@SYMTestActions			SQLite library single-update performance test.
   1.357 +@SYMTestExpectedResults Test must not fail
   1.358 +@SYMREQ					REQ8782
   1.359 +*/
   1.360 +void SqliteSingleUpdateTest(TPerfTestMode aPerfTestMode, const char aSingleUpdateSql[], TInt aUpdateRecId)
   1.361 +	{
   1.362 +	int err;
   1.363 +	unsigned int fc;
   1.364 +	char tmp[10];
   1.365 +	
   1.366 +	TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
   1.367 +	TEST(!TheDb2);
   1.368 +	err = sqlite3_open(TestDbName(), &TheDb2);
   1.369 +	TEST2(err, SQLITE_OK);
   1.370 +	ExecSqliteConfig(aPerfTestMode);
   1.371 +
   1.372 +	sprintf(tmp, "%d", aUpdateRecId);
   1.373 +	strcpy(TheSqlBuf2, aSingleUpdateSql);
   1.374 +	strcat(TheSqlBuf2, tmp);
   1.375 +	fc = FastCounterValue();
   1.376 +	err = sqlite3_exec(TheDb2, TheSqlBuf2, 0, 0, 0);
   1.377 +	StorePerfTestResult(aPerfTestMode, EPerfTestSingleUpdate, FastCounterValue() - fc);
   1.378 +	TEST2(err, SQLITE_OK);
   1.379 +	
   1.380 +	sqlite3_close(TheDb2);
   1.381 +	TheDb2 = 0;
   1.382 +	}
   1.383 +
   1.384 +/**
   1.385 +@SYMTestCaseID			SYSLIB-SQLITE3-UT-4024
   1.386 +@SYMTestCaseDesc		SQLite library single-delete performance test.
   1.387 +						The test deletes one record and stores 
   1.388 +						the execution time for later use (comparison and printing).
   1.389 +						The ID of the deleted record is exactly the same as the ID of the deleted
   1.390 +						record, used by SYSLIB-SQLITE3-UT-4016 test case.
   1.391 +						The results of this test case will be compared against the results of
   1.392 +						the SYSLIB-SQLITE3-UT-4016 test case - "SQL server single-delete performance test".
   1.393 +@SYMTestPriority		High
   1.394 +@SYMTestActions			SQLite library single-delete performance test.
   1.395 +@SYMTestExpectedResults Test must not fail
   1.396 +@SYMREQ					REQ8782
   1.397 +*/
   1.398 +void SqliteSingleDeleteTest(TPerfTestMode aPerfTestMode, const char aSingleDeleteSql[], TInt aDeleteRecId)
   1.399 +	{
   1.400 +	int err;
   1.401 +	unsigned int fc;
   1.402 +	char tmp[10];
   1.403 +	
   1.404 +	TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
   1.405 +	TEST(!TheDb2);
   1.406 +	err = sqlite3_open(TestDbName(), &TheDb2);
   1.407 +	TEST2(err, SQLITE_OK);
   1.408 +	ExecSqliteConfig(aPerfTestMode);
   1.409 +
   1.410 +	sprintf(tmp, "%d", aDeleteRecId);
   1.411 +	strcpy(TheSqlBuf2, aSingleDeleteSql);
   1.412 +	strcat(TheSqlBuf2, tmp);
   1.413 +	fc = FastCounterValue();
   1.414 +	err = sqlite3_exec(TheDb2, TheSqlBuf2, 0, 0, 0);
   1.415 +	StorePerfTestResult(aPerfTestMode, EPerfTestSingleDelete, FastCounterValue() - fc);
   1.416 +	TEST2(err, SQLITE_OK);
   1.417 +	
   1.418 +	sqlite3_close(TheDb2);
   1.419 +	TheDb2 = 0;
   1.420 +	}
   1.421 +
   1.422 +/**
   1.423 +@SYMTestCaseID			SYSLIB-SQLITE3-UT-4025
   1.424 +@SYMTestCaseDesc		SQLite library single-select performance test.
   1.425 +						The test selects one record and stores 
   1.426 +						the execution time for later use (comparison and printing).
   1.427 +						The ID of the selected record is exactly the same as the ID of the selected
   1.428 +						record, used by SYSLIB-SQLITE3-UT-4017 test case.
   1.429 +						The results of this test case will be compared against the results of
   1.430 +						the SYSLIB-SQLITE3-UT-4017 test case - "SQL server single-select performance test".
   1.431 +@SYMTestPriority		High
   1.432 +@SYMTestActions			SQLite library single-select performance test.
   1.433 +@SYMTestExpectedResults Test must not fail
   1.434 +@SYMREQ					REQ8782
   1.435 +*/
   1.436 +void SqliteSingleSelectTest(TPerfTestMode aPerfTestMode, const char aSingleSelectSql[], TInt aSelectRecId)
   1.437 +	{
   1.438 +	int err;
   1.439 +	const char* tail = 0;
   1.440 +	sqlite3_stmt* stmt = 0;
   1.441 +	int recCnt = 0;
   1.442 +	unsigned int fc;
   1.443 +	char tmp[10];
   1.444 +	
   1.445 +	TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
   1.446 +	TEST(!TheDb2);
   1.447 +	err = sqlite3_open(TestDbName(), &TheDb2);
   1.448 +	TEST2(err, SQLITE_OK);
   1.449 +	ExecSqliteConfig(aPerfTestMode);
   1.450 +
   1.451 +	sprintf(tmp, "%d", aSelectRecId);
   1.452 +	strcpy(TheSqlBuf2, aSingleSelectSql);
   1.453 +	strcat(TheSqlBuf2, tmp);
   1.454 +	
   1.455 +	err = sqlite3_prepare(TheDb2, TheSqlBuf2, -1, &stmt, &tail);
   1.456 +	TEST2(err, SQLITE_OK);
   1.457 +	
   1.458 +	fc = FastCounterValue();
   1.459 +	while((err = sqlite3_step(stmt)) == SQLITE_ROW)
   1.460 +		{
   1.461 +		__int64 i64;
   1.462 +		double d;
   1.463 +		const unsigned short* t;
   1.464 +		const unsigned char* b;
   1.465 +		
   1.466 +		i64 = sqlite3_column_int64(stmt, 0);
   1.467 +		UNUSED_VAR(i64);
   1.468 +		d = sqlite3_column_double(stmt, 1);
   1.469 +		UNUSED_VAR(d);
   1.470 +		t = (const unsigned short*)sqlite3_column_text16(stmt, 2);
   1.471 +		UNUSED_VAR(t);
   1.472 +		b = (const unsigned char*)sqlite3_column_blob(stmt, 3);
   1.473 +		UNUSED_VAR(b);
   1.474 +		++recCnt;
   1.475 +		}
   1.476 +	StorePerfTestResult(aPerfTestMode, EPerfTestSingleSelect, FastCounterValue() - fc);
   1.477 +	TEST2(err, SQLITE_DONE);
   1.478 +	TEST2(recCnt, 1);
   1.479 +
   1.480 +	sqlite3_finalize(stmt);	
   1.481 +	sqlite3_close(TheDb2);
   1.482 +	TheDb2 = 0;
   1.483 +	}
   1.484 +
   1.485 +void SqliteInitialize(TPerfTestMode aMode)
   1.486 +	{
   1.487 +	if(aMode == EPerfTestSqliteSqlMode)
   1.488 +		{
   1.489 +		const TInt KSqliteLookAsideCellSize = 128;
   1.490 +		const TInt KSqliteLookAsideCellCount = 512;
   1.491 +		int err;
   1.492 +		err = sqlite3_config(SQLITE_CONFIG_LOOKASIDE, KSqliteLookAsideCellSize, KSqliteLookAsideCellCount);
   1.493 +		TEST2(err, SQLITE_OK);
   1.494 +		sqlite3_soft_heap_limit(1024 * 1024);
   1.495 +		err = sqlite3_enable_shared_cache(1);
   1.496 +		TEST2(err, SQLITE_OK);
   1.497 +		}
   1.498 +	}
   1.499 +
   1.500 +void SqliteFinalize(TPerfTestMode aMode)
   1.501 +	{
   1.502 +	if(aMode == EPerfTestSqliteSqlMode)
   1.503 +		{
   1.504 +		(void)sqlite3_enable_shared_cache(0);
   1.505 +		sqlite3_soft_heap_limit(0);
   1.506 +		}
   1.507 +	sqlite3_shutdown();
   1.508 +	}