19 #include <sqldb.h> |
19 #include <sqldb.h> |
20 #include "t_sqlcmdlineutil.h" |
20 #include "t_sqlcmdlineutil.h" |
21 |
21 |
22 RTest TheTest(_L("t_sqlperformance5 test")); |
22 RTest TheTest(_L("t_sqlperformance5 test")); |
23 RSqlDatabase TheDb; |
23 RSqlDatabase TheDb; |
|
24 RFs TheFs; |
|
25 RFile TheLogFile; |
24 |
26 |
25 _LIT(KDbName, "c:\\test\\t_sqlperformance5.db"); |
27 _LIT(KDbName, "c:\\test\\t_sqlperformance5.db"); |
26 |
28 |
27 TFileName TheDbFileName; |
29 TFileName TheDbFileName; |
28 TBuf<200> TheTestTitle; |
30 TBuf<200> TheTestTitle; |
97 |
104 |
98 /////////////////////////////////////////////////////////////////////////////////////// |
105 /////////////////////////////////////////////////////////////////////////////////////// |
99 |
106 |
100 void TestEnvInit() |
107 void TestEnvInit() |
101 { |
108 { |
102 RFs fs; |
109 TInt err = TheFs.Connect(); |
103 TInt err = fs.Connect(); |
110 TEST2(err, KErrNone); |
104 TEST2(err, KErrNone); |
111 err = TheFs.MkDirAll(TheDbFileName); |
105 err = fs.MkDirAll(TheDbFileName); |
|
106 TEST(err == KErrNone || err == KErrAlreadyExists); |
112 TEST(err == KErrNone || err == KErrAlreadyExists); |
107 fs.Close(); |
113 if(TheCmdLineParams.iLogFileName.Length() > 0) |
|
114 { |
|
115 err = TheLogFile.Replace(TheFs, TheCmdLineParams.iLogFileName, EFileRead | EFileWrite); |
|
116 TEST2(err, KErrNone); |
|
117 LogConfig(TheLogFile, TheCmdLineParams); |
|
118 } |
108 } |
119 } |
109 |
120 |
110 TInt TimeDiffUs(TUint32 aStartTicks, TUint32 aEndTicks) |
121 TInt TimeDiffUs(TUint32 aStartTicks, TUint32 aEndTicks) |
111 { |
122 { |
112 if(TheFastCounterFreq == 0) |
123 if(TheFastCounterFreq == 0) |
362 |
373 |
363 stmt2.Close(); |
374 stmt2.Close(); |
364 stmt1.Close(); |
375 stmt1.Close(); |
365 TheDb.Close(); |
376 TheDb.Close(); |
366 |
377 |
367 TheTest.Printf(_L("==Create database, time=%d microseconds\r\n"), TheCreateDbTime); |
378 TheTest.Printf(_L("==Create database: %d us\r\n"), TheCreateDbTime); |
368 TheTest.Printf(_L("==Create tables, time=%d microseconds\r\n"), TheCreateTablesTime); |
379 TheTest.Printf(_L("==Create tables: %d us\r\n"), TheCreateTablesTime); |
369 TheTest.Printf(_L("==Bind parameters time, time=%d microseconds\r\n"), TheBindParamsTime); |
380 TheTest.Printf(_L("==Bind parameters time: %d us\r\n"), TheBindParamsTime); |
370 TheTest.Printf(_L("==Temp tables, statement exec, time=%d microseconds\r\n"), TheStmtExecTime); |
381 TheTest.Printf(_L("==Temp tables, statement exec: %d us\r\n"), TheStmtExecTime); |
371 TheTest.Printf(_L("==Temp tables, statement reset, time=%d microseconds\r\n"), TheStmtResetTime); |
382 TheTest.Printf(_L("==Temp tables, statement reset: %d us\r\n"), TheStmtResetTime); |
372 TheTest.Printf(_L("==Populate temp tables, time=%d microseconds\r\n"), ThePopulateTempTableTime); |
383 TheTest.Printf(_L("==Populate temp tables: %d us\r\n"), ThePopulateTempTableTime); |
373 TheTest.Printf(_L("==Copy temp tables to main tables, time=%d microseconds\r\n"), TheFlushTime); |
384 TheTest.Printf(_L("==Copy temp tables to main tables: %d us\r\n"), TheFlushTime); |
|
385 if(TheCmdLineParams.iLogFileName.Length() > 0) |
|
386 { |
|
387 TBuf8<200> buf; |
|
388 buf.Format(_L8("Create database¬%d¬us\r\n"), TheCreateDbTime); |
|
389 (void)TheLogFile.Write(buf); |
|
390 buf.Format(_L8("Create tables¬%d¬us\r\n"), TheCreateTablesTime); |
|
391 (void)TheLogFile.Write(buf); |
|
392 buf.Format(_L8("Bind parameters¬%d¬us\r\n"), TheBindParamsTime); |
|
393 (void)TheLogFile.Write(buf); |
|
394 buf.Format(_L8("Temp tables,statement exec¬%d¬us\r\n"), TheStmtExecTime); |
|
395 (void)TheLogFile.Write(buf); |
|
396 buf.Format(_L8("Temp tables,statement reset¬%d¬us\r\n"), TheStmtResetTime); |
|
397 (void)TheLogFile.Write(buf); |
|
398 buf.Format(_L8("Populate temp tables¬%d¬us\r\n"), ThePopulateTempTableTime); |
|
399 (void)TheLogFile.Write(buf); |
|
400 buf.Format(_L8("Copy temp tables to main tables¬%d¬us\r\n"), TheFlushTime); |
|
401 (void)TheLogFile.Write(buf); |
|
402 } |
374 } |
403 } |
375 |
404 |
376 void DoTestsL() |
405 void DoTestsL() |
377 { |
406 { |
378 TheTestTitle.Format(_L("@SYMTestCaseID:PDS-SQL-CT-4205 Create database, encoding: \"%S\", page size: %d\r\n"), |
407 TheTestTitle.Format(_L("@SYMTestCaseID:PDS-SQL-CT-4205 Create database, encoding: \"%S\", page size: %d\r\n"), |
397 |
426 |
398 __UHEAP_MARK; |
427 __UHEAP_MARK; |
399 |
428 |
400 GetCmdLineParamsAndSqlConfigString(TheTest, _L("t_sqlperformance5"), TheCmdLineParams, TheSqlConfigString); |
429 GetCmdLineParamsAndSqlConfigString(TheTest, _L("t_sqlperformance5"), TheCmdLineParams, TheSqlConfigString); |
401 PrepareDbName(KDbName, TheCmdLineParams.iDriveName, TheDbFileName); |
430 PrepareDbName(KDbName, TheCmdLineParams.iDriveName, TheDbFileName); |
402 SetSoftHeapLimit(TheCmdLineParams.iSoftHeapLimitKb); |
431 SetSoftHeapLimit(TheTest, TheCmdLineParams.iSoftHeapLimitKb); |
403 |
432 |
404 TheTest.Printf(_L("==Databases: %S\r\n"), &TheDbFileName); |
433 TheTest.Printf(_L("==Databases: %S\r\n"), &TheDbFileName); |
405 |
434 |
406 TestEnvDestroy(); |
|
407 TestEnvInit(); |
435 TestEnvInit(); |
408 TRAPD(err, DoTestsL()); |
436 TRAPD(err, DoTestsL()); |
409 TestEnvDestroy(); |
437 TestEnvDestroy(); |
410 TEST2(err, KErrNone); |
438 TEST2(err, KErrNone); |
411 |
439 |