kerneltest/f32test/server/t_wcache.cpp
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
--- a/kerneltest/f32test/server/t_wcache.cpp	Tue Aug 31 16:34:26 2010 +0300
+++ b/kerneltest/f32test/server/t_wcache.cpp	Wed Sep 01 12:34:56 2010 +0100
@@ -28,8 +28,6 @@
 #include <f32dbg.h>
 #include "t_server.h"
 #include <e32twin.h>
-#include <hal.h>
-#include "tf32testtimer.h"
 
 const TInt KTotalCacheSize = 32 * 1024 * 1024;
 const TInt KDefaultCacheSize = (128 + 12) * 1024; 	// This size is the default configuration size
@@ -91,6 +89,7 @@
 const TInt KOneMeg = KOneK * 1024;
 const TInt KBlockSize = KOneK;
 const TInt KWaitRequestsTableSize = 256;
+const TInt KMs = 1000; 
 
 TInt gSecondFileSize = 0; 
 TInt gFirstFileSize = 0;
@@ -103,6 +102,9 @@
 TBuf16<25> gCurrentFile;
 
 TInt gNextFile = 0;
+TTime gTime1;
+TTime gTime2;
+
 
 // Concurrent Threads
 RThread gThread1;
@@ -511,22 +513,25 @@
 	
 	@return time taken to perform the operation in uS
 */
-TTimeIntervalMicroSeconds WriteTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aBlockSize, TInt aMode) 
+TInt WriteTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aBlockSize, TInt aMode) 
 	{
 	RTest test(_L("T_WCACHE"));
 
+	TTime startTime;
+	TTime endTime;
 	TInt r = 0;
-
-    TF32TestTimer timer;
-	timer.Start();
+	
+	startTime.HomeTime();
 	
 	r = WriteFile(gTheFs,aFile, aFileName , aSize * KOneK, aBlockSize, gBufWritePtr, aMode);
 	test_KErrNone(r);
-
-	timer.Stop();	
-	gTimeTakenBigFile = timer.Time();
+	
+	endTime.HomeTime();
+	
+	gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
+	
 	test.Close();
-	return timer.Time();        
+	return I64LOW(gTimeTakenBigFile.Int64());
 	}
 
 /** Measure the time taken for this file to be read synchronously
@@ -540,16 +545,18 @@
 	@return time taken to perform the operation in uS
 
 */
-TTimeIntervalMicroSeconds ReadTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aBlockSize, TInt aMode) 
+TInt ReadTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aBlockSize, TInt aMode) 
 	{
-    TF32TestTimer timer;
-	timer.Start();
+	TTime startTime;
+	TTime endTime;
+	
+	startTime.HomeTime();
 	ReadFile(gTheFs,aFile, aFileName, aSize * KOneK, aBlockSize, aMode);
-	timer.Stop();
+	endTime.HomeTime();
 	
-	gTimeTakenBigFile = timer.Time();
-        	
-	return timer.Time();
+	gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
+	
+	return I64LOW(gTimeTakenBigFile.Int64()) ;
 	}
 
 /** Read asynchronously the test file from the disc
@@ -562,19 +569,22 @@
 
 	@return time taken to perform the operation in uS
 */
-TTimeIntervalMicroSeconds ReadAsyncTestFile(RFile& file, TDes16& aFile, TInt aSize, TInt aBlockSize, TInt aMode) 
+TInt ReadAsyncTestFile(RFile& file, TDes16& aFile, TInt aSize, TInt aBlockSize, TInt aMode) 
 	{
+	TTime startTime;
+	TTime endTime;
 	TRequestStatus status[KWaitRequestsTableSize];
-    TF32TestTimer timer;
-	timer.Start();
+	
+	startTime.HomeTime();
 	
 	ReadFileAsync(gTheFs, file, aFile, aSize * KOneK, aBlockSize, status, aMode);
 	WaitForAll(status,  (aSize * KOneK)/KBlockSize);
-	timer.Stop();	
-		
-	gTimeTakenBigFile = timer.Time();
+	
+	endTime.HomeTime();
 	
-	return timer.Time();
+	gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
+	
+	return I64LOW(gTimeTakenBigFile.Int64());
 	}
 
 /** Read asynchronously the test file from the disc
@@ -586,19 +596,22 @@
 
 	@return time taken to perform the operation in uS
 */
-TTimeIntervalMicroSeconds WriteAsyncTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aMode) 
+TInt WriteAsyncTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aMode) 
 	{
+	TTime startTime;
+	TTime endTime;
 	TRequestStatus status[KWaitRequestsTableSize];
-    TF32TestTimer timer;
-    timer.Start();
+	
+	startTime.HomeTime();
 	
 	WriteFileAsync(gTheFs, aFile, aFileName, aSize * KOneK, aMode, status );
 	WaitForAll(status, (aSize * KOneK)/KBlockSize);
-	timer.Stop();	
+	
+	endTime.HomeTime();
 	
-	gTimeTakenBigFile = timer.Time();
+	gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
 	
-	return timer.Time();
+	return I64LOW(gTimeTakenBigFile.Int64());
 	}
 
 /**  Test Boundaries
@@ -608,9 +621,9 @@
 void TestBoundaries()
 	{
 	TInt r = 0;
-	TTimeIntervalMicroSeconds time = 0;
-	TTimeIntervalMicroSeconds rtime = 0;
-	TTimeIntervalMicroSeconds tcreate = 0;
+	TInt time = 0;
+	TInt rtime = 0;
+	TInt tcreate = 0;
 	RFile fileWriter;
 	RFile fileWriter2;
 	RFile fileReader;
@@ -628,22 +641,21 @@
 		test.Printf(_L("\nSync: Write from 1 K to %d K \n"), i); 
 
 		tcreate = WriteTestFile(fileWriter, gSecondFile, i, KBlockSize, EFileShareAny|EFileWrite|EFileWriteDirectIO);
-		test.Printf(_L("Time to write %d K without caching: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(tcreate));	
+		test.Printf(_L("Time to write %d K without caching: %d mS\n"), i, tcreate/KMs);	
 		fileWriter.Close();
 
 		time =  WriteTestFile(fileWriter2, gFirstFile, i, KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered);
-		test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(time));
+		test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), i, time/KMs);
 
 		rtime = ReadTestFile(fileReader, gFirstFile, i, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered);
-		test.Printf(_L("Time to read %d K from the cache: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(rtime));
+		test.Printf(_L("Time to read %d K from the cache: %d mS\n"), i, rtime/KMs);
+
 
 		fileReader.Close();	
 		fileWriter2.Close();
 		
 		#if !defined(__WINS__)
-            test(tcreate > TTimeIntervalMicroSeconds(0));  // test measured time is correct
-			test(tcreate > time);
-            test(tcreate > rtime); 
+			test((tcreate > time) || (tcreate > rtime)); 
 		#endif
 
 		r = gTheFs.Delete(gFirstFile);
@@ -664,23 +676,21 @@
 		test.Printf(_L("\nAsync: Write from 1 K to %d K \n"), i); 
 
 		tcreate = WriteAsyncTestFile(fileWriter, gSecondFile, i, EFileShareAny|EFileWrite|EFileWriteDirectIO);
-		test.Printf(_L("Time to write %d K without caching: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(tcreate));
+		test.Printf(_L("Time to write %d K without caching: %d mS\n"), i, tcreate/KMs);	
 		fileWriter.Close();
 
 		time =  WriteAsyncTestFile(fileWriter2, gFirstFile, i,EFileShareAny|EFileWrite|EFileWriteBuffered);
-		test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(time));
+		test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), i, time/KMs);
 
 
 		rtime = ReadAsyncTestFile(fileReader, gFirstFile, i, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered);
-		test.Printf(_L("Time to read %d K from the cache: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(rtime));
+		test.Printf(_L("Time to read %d K from the cache: %d mS\n"), i, rtime/KMs);
 
 		fileReader.Close();	
 		fileWriter2.Close();
 		
 		#if !defined(__WINS__)
-            test(tcreate > TTimeIntervalMicroSeconds(0));  // test measured time is correct
-			test(tcreate > time);
-            test(tcreate > rtime);
+			test((tcreate > time) || (tcreate > rtime));  
 		#endif
 
 		r = gTheFs.Delete(gFirstFile);
@@ -739,16 +749,17 @@
 	
 	@return returns the time that took to do the verification in mS, fails if the file is not corrupted/modified
 */
-TTimeIntervalMicroSeconds ReadTestFileVerif(TDes16& aFile)
+TInt ReadTestFileVerif(TDes16& aFile)
 	{
+	TTime startTime;
+	TTime endTime;
 	TInt r = 0;
 	TInt size = 0;
 	RFile fileRead;
 	TInt corrupt = 0;
 	TBool isFat=IsFSFAT(gTheFs,gDrive);
-
-    TF32TestTimer timer;
-	timer.Start();
+	
+	startTime.HomeTime();
 	
 	r = fileRead.Open(gTheFs,aFile,EFileShareAny|EFileRead|EFileReadBuffered|EFileReadAheadOff);
 	test_KErrNone(r);
@@ -780,11 +791,12 @@
 	fileRead.Close();
 	
 	test(corrupt>0); // Ensure the cache returns the changed content 
-	timer.Stop();	
+	
+	endTime.HomeTime();
 	
-	gTimeTakenBigFile = timer.Time();
+	gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
 	
-	return timer.Time();
+	return I64LOW(gTimeTakenBigFile.Int64()) / KMs;
 	}
 
 /**  Modifies the second file
@@ -798,7 +810,7 @@
 	TPtr8 dummyPtr(NULL, 0);	
 
 	TRAPD(res,dummy = HBufC8::NewL(4));
-	test_Value(res, res == KErrNone && dummy != NULL);
+	test(res == KErrNone && dummy != NULL);
 		
 	dummyPtr.Set(dummy->Des());
 	FillBuffer(dummyPtr, 4, '1');
@@ -828,8 +840,8 @@
 LOCAL_C void TestIntegrity()
 	{
 	TInt r = 0;
-	TTimeIntervalMicroSeconds time;
-	TTimeIntervalMicroSeconds tcreate = 0;
+	TInt time;
+	TInt tcreate = 0;
 	RFile file;
 	
 	// Modify file in some position 
@@ -838,14 +850,14 @@
 	test.Printf(_L("\nSync: Write from 1 K to %d K \n"), 255); 
 
 	tcreate = WriteTestFile(file, gSecondFile, 255, KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered);
-	test.Printf(_L("Time to write %d K with caching: %d mS\n"), 255, TF32TestTimer::TimeInMilliSeconds(tcreate));	
+	test.Printf(_L("Time to write %d K with caching: %d mS\n"), 255, tcreate/KMs);	
 	file.Close();
 
 	test.Printf(_L("Mess the content that is still in the cache\n"));
 	CorruptSecondFile(); 
 	
 	time = ReadTestFileVerif(gSecondFile);	
-	test.Printf(_L("Time taken to verify: %ld\n"),time.Int64());
+	test.Printf(_L("Time taken to verify: %d\n"),time);
 	
 	test.Printf(_L("Integrity verified\n"));
 
@@ -881,7 +893,7 @@
 	TInt KBigBifferSize = 32 * KOneK;
 	
 	TRAPD(res,bigBuf = HBufC8::NewL(KBigBifferSize));
-	test_Value(res, res == KErrNone && bigBuf != NULL);
+	test(res == KErrNone && bigBuf != NULL);
 		
 	TPtr8 bigBufWritePtr(NULL, 0);	
 	bigBufWritePtr.Set(bigBuf->Des());
@@ -947,7 +959,7 @@
 	HBufC8* bigBuf = NULL;
 	const TInt KBigBifferSize = 32 * 1024;
 	TRAPD(res,bigBuf = HBufC8::NewL(KBigBifferSize));
-	test_Value(res, res == KErrNone && bigBuf != NULL);
+	test(res == KErrNone && bigBuf != NULL);
 		
 	TPtr8 bigBufWritePtr(NULL, 0);	
 	bigBufWritePtr.Set(bigBuf->Des());
@@ -1004,7 +1016,7 @@
 	TPtr8 bufPtr(NULL, 0);	
 	
 	TRAPD(res,buf = HBufC8::NewL(2));
-	test_Value(res, res == KErrNone && buf != NULL);
+	test(res == KErrNone && buf != NULL);
 	bufPtr.Set(buf->Des());
 	
 	directory = gSessionPath;
@@ -1166,7 +1178,7 @@
 */
 void TestRemoval()
 	{	
-	TTimeIntervalMicroSeconds time = 0, rtime = 0;
+	TInt time = 0, rtime = 0;
 	RFile file1, file2;
 	
 		 	
@@ -1202,7 +1214,7 @@
 
 
 	TRAPD(res,gBuf = HBufC8::NewL(KBlockSize+1));
-	test_Value(res, res == KErrNone && gBuf != NULL);
+	test(res == KErrNone && gBuf != NULL);
 		
 	gBufWritePtr.Set(gBuf->Des());
 	FillBuffer(gBufWritePtr, KBlockSize, 'A');
@@ -1215,7 +1227,7 @@
 	test.Printf(_L("\nSync: Write from 1 K to 254 K \n")); 
 
 	time =  WriteTestFile(file1, gSecondFile, KMinSize, KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered);
-	test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), KMinSize, TF32TestTimer::TimeInMilliSeconds(time));
+	test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), KMinSize, time/KMs);
 	test.Printf(_L("Remove MMC card,! and then press a key\n"));
 	test.Getch();
 
@@ -1223,7 +1235,7 @@
 	test.Getch();
 
 	rtime = ReadTestFile(file2, gSecondFile, KMinSize, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered);
-	test.Printf(_L("Time to read %d K from the cache: %d mS\n"), KMinSize, TF32TestTimer::TimeInMilliSeconds(rtime));
+	test.Printf(_L("Time to read %d K from the cache: %d mS\n"), KMinSize, rtime/KMs);
 
 	test.Printf(_L("Remove MMC card! and then press a key\n"));
 	test.Getch();
@@ -1235,7 +1247,7 @@
 	test.Printf(_L("\nSync: Write from 1 K to 255 K \n")); 
 
 	time =  WriteTestFile(file1, gFirstFile, KMinSize + 1 , KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered);
-	test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), KMinSize + 1, TF32TestTimer::TimeInMilliSeconds(time));
+	test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), KMinSize + 1, time/KMs);
 	test.Printf(_L("Remove MMC card and delete the file //F32-TST//FFFFFFF0.TXT and then press a key\n"));
 	test.Getch();
 
@@ -1243,7 +1255,7 @@
 	test.Getch();
 
 	rtime = ReadTestFile(file2, gFirstFile, KMinSize + 1, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered);
-	test.Printf(_L("Time to read %d K from the cache: %d mS\n"), KMinSize + 1, TF32TestTimer::TimeInMilliSeconds(rtime));
+	test.Printf(_L("Time to read %d K from the cache: %d mS\n"), KMinSize + 1, rtime/KMs);
 
 	test.Printf(_L("Remove MMC card! and then press a key\n"));
 	test.Getch();
@@ -1287,7 +1299,7 @@
 
 
 	TRAPD(res,gBuf = HBufC8::NewL(KBlockSize+1));
-	test_Value(res, res == KErrNone && gBuf != NULL);
+	test(res == KErrNone && gBuf != NULL);
 		
 	gBufWritePtr.Set(gBuf->Des());
 	FillBuffer(gBufWritePtr, KBlockSize, 'A');
@@ -1355,8 +1367,10 @@
 	TVolumeInfo volInfo;
 	TInt r = gTheFs.Volume(volInfo, gDrive);
 	test_KErrNone(r);
-	gMediaSize = volInfo.iFree;	
-	test.Printf(_L("\nMedia free space: %d MB\n"), gMediaSize/KOneMeg);
+	gMediaSize = volInfo.iSize;
+	
+	test.Printf(_L("\nMedia size: %d MB\n"), gMediaSize/KOneMeg  );
+	
 	return ETrue;
 	}