kerneltest/f32test/bench/t_fsysbm.cpp
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
equal deleted inserted replaced
43:c1f20ce4abcf 44:3e88ff8f41d5
    29 
    29 
    30 #define SYMBIAN_TEST_EXTENDED_BUFFER_SIZES	// test using a greater number of buffer sizes
    30 #define SYMBIAN_TEST_EXTENDED_BUFFER_SIZES	// test using a greater number of buffer sizes
    31 //#define SYMBIAN_TEST_COPY					// read from one drive and write to another
    31 //#define SYMBIAN_TEST_COPY					// read from one drive and write to another
    32 
    32 
    33 
    33 
    34 RTest test(_L("File System Benchmarks"));
    34 GLDEF_D RTest test(_L("File System Benchmarks"));
    35 
    35 
    36 static const TUint K1K = 1024;								// 1K
    36 static const TUint K1K = 1024;								// 1K
    37 static const TUint K1M = 1024 * 1024;						// 1M
    37 static const TUint K1M = 1024 * 1024;						// 1M
    38 static const TUint K2M = 2 * K1M;						    // 2M
    38 static const TUint K2M = 2 * K1M;						    // 2M
    39 
    39 
    40 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
    40 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
    41 const TInt64 KGb  	= 1 << 30;								// 1GB
    41 const TInt64 KGb  	= 1 << 30;
    42 const TInt64 K3GB   = 3 * KGb;								// 3GB
    42 const TInt64 K3GB   = 3 * KGb;
    43 const TInt64 K4GB   = 4 * KGb;								// 4GB
    43 const TInt64 K4GB   = 4 * KGb;
    44 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
    44 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
    45 
    45 
    46 #if defined(__WINS__)
    46 #if defined(__WINS__)
    47 static TInt KMaxFileSize = 256 * K1K;					// 256K
    47 LOCAL_D TInt KMaxFileSize = 256 * K1K;						// 256K
    48 //static TInt KMaxFileSize = K1M;						// 1M
    48 //LOCAL_D TInt KMaxFileSize = K1M;							// 1M
    49 #else
    49 #else
    50 //static TInt KMaxFileSize = 256 * K1K;					// 256K
    50 //LOCAL_D TInt KMaxFileSize = 256 * K1K;					// 256K
    51 //static TInt KMaxFileSize = K1M;						// 1M
    51 //LOCAL_D TInt KMaxFileSize = K1M;							// 1M
    52 static TInt KMaxFileSize = K2M;							// 2M
    52 LOCAL_D TInt KMaxFileSize = K2M;							// 2M
    53 #endif
    53 #endif
    54 
    54 
    55 const TTimeIntervalMicroSeconds32 KFloatingPointTestTime = 10000000;	// 10 seconds
    55 const TTimeIntervalMicroSeconds32 KFloatingPointTestTime = 10000000;	// 10 seconds
    56 static const TInt KHeapSize = 0x4000;
    56 LOCAL_D const TInt KHeapSize = 0x4000;
    57 
    57 
    58 static TPtr8 DataBuf(NULL, KMaxFileSize,KMaxFileSize);
    58 LOCAL_D TPtr8 DataBuf(NULL, KMaxFileSize,KMaxFileSize);
    59 static HBufC8* DataBufH = NULL;
    59 LOCAL_D HBufC8* DataBufH = NULL;
    60 
    60 
    61 static RSharedChunkLdd Ldd;
    61 LOCAL_D RSharedChunkLdd Ldd;
    62 static RChunk TheChunk;
    62 LOCAL_D RChunk TheChunk;
    63 static TInt PageSize;
    63 LOCAL_D TInt PageSize;
    64 const TUint ChunkSize = KMaxFileSize;
    64 const TUint ChunkSize = KMaxFileSize;
    65 
    65 
    66 
    66 
    67 static RFile File, File2;
    67 LOCAL_D RFile File, File2;
    68 #if defined SYMBIAN_TEST_COPY
    68 LOCAL_D TChar gDriveToTest2;
    69 static TChar gDriveToTest2;
       
    70 #endif
       
    71 
    69 
    72 // if enabled, Read and Write operations are not boundary aligned.
    70 // if enabled, Read and Write operations are not boundary aligned.
    73 static TBool gMisalignedReadWrites = EFalse;
    71 LOCAL_D TBool gMisalignedReadWrites = EFalse;
    74 
    72 
    75 // read & write caching enabled flags - may be overridden by +/-r +/-w command line switches
    73 // read & write caching enabled flags - may be overriden by +/-r +/-w command line switches
    76 static TBool gReadCachingOn  = EFalse;
    74 LOCAL_D TBool gReadCachingOn  = EFalse;
    77 static TBool gWriteCachingOn = EFalse;
    75 LOCAL_D TBool gWriteCachingOn = EFalse;
    78 
    76 
    79 // if enabled, timings are for write AND flush
    77 // if enabled, timings are for write AND flush
    80 static TBool gFlushAfterWrite = ETrue;
    78 LOCAL_D TBool gFlushAfterWrite = ETrue;
    81 
    79 
    82 // if enabled, contiguous shared memory is used for Data buffer
    80 // if enabled, contiguous shared memory is used for Data buffer
    83 static TBool gSharedMemory = EFalse;
    81 LOCAL_D TBool gSharedMemory = EFalse;
    84 
    82 
    85 // if enabled, fragmented shared memory is used for Data buffer
    83 // if enabled, fragmented shared memory is used for Data buffer
    86 static TBool gFragSharedMemory = EFalse;
    84 LOCAL_D TBool gFragSharedMemory = EFalse;
    87 
    85 
    88 // if enabled, file is opened in EFileSequential (non-Rugged) file mode for write tests
    86 LOCAL_D TInt gFastCounterFreq;
    89 // - may be overridden by +/-q command line switches
    87 
    90 static TBool gFileSequentialModeOn = EFalse;
    88 
    91 
    89 
    92 static TInt gFastCounterFreq;
    90 LOCAL_C void RecursiveRmDir(const TDesC& aDes)
    93 
       
    94 
       
    95 
       
    96 static void RecursiveRmDir(const TDesC& aDes)
       
    97 //
    91 //
    98 // Delete directory contents recursively
    92 // Delete directory contents recursively
    99 //
    93 //
   100 	{
    94 	{
   101 	CDir* pD;
    95 	CDir* pD;
   102 	TFileName n=aDes;
    96 	TFileName n=aDes;
   103 	n.Append(_L("*"));
    97 	n.Append(_L("*"));
   104 	TInt r=TheFs.GetDir(n,KEntryAttMaskSupported,EDirsLast,pD);
    98 	TInt r=TheFs.GetDir(n,KEntryAttMaskSupported,EDirsLast,pD);
   105 	if (r==KErrNotFound || r==KErrPathNotFound)
    99 	if (r==KErrNotFound || r==KErrPathNotFound)
   106 		return;
   100 		return;
   107 	test_KErrNone(r);
   101 	test(r==KErrNone);
   108 	TInt count=pD->Count();
   102 	TInt count=pD->Count();
   109 	TInt i=0;
   103 	TInt i=0;
   110 	while (i<count)
   104 	while (i<count)
   111 		{
   105 		{
   112 		const TEntry& e=(*pD)[i++];
   106 		const TEntry& e=(*pD)[i++];
   119 		else
   113 		else
   120 			{
   114 			{
   121 			TFileName fileName;
   115 			TFileName fileName;
   122 			fileName.Format(_L("%S%S"),&aDes,&e.iName);
   116 			fileName.Format(_L("%S%S"),&aDes,&e.iName);
   123 			r=TheFs.Delete(fileName);
   117 			r=TheFs.Delete(fileName);
   124 			test_KErrNone(r);
   118 			test(r==KErrNone);
   125 			}
   119 			}
   126 		}
   120 		}
   127 	delete pD;
   121 	delete pD;
   128 	r=TheFs.RmDir(aDes);
   122 	r=TheFs.RmDir(aDes);
   129 	test_KErrNone(r);
   123 	test(r==KErrNone);
   130 	}
   124 	}
   131 
   125 
   132 
   126 
   133 void static ClearSessionDirectory()
   127 void LOCAL_C ClearSessionDirectory()
   134 //
   128 //
   135 // Delete the contents of F32-TST
   129 // Delete the contents of F32-TST
   136 //
   130 //
   137 	{
   131 	{
   138 	TParse sessionPath;
   132 	TParse sessionPath;
   139 	TInt r=TheFs.Parse(_L("\\F32-TST\\"),_L(""),sessionPath);
   133 	TInt r=TheFs.Parse(_L("\\F32-TST\\"),_L(""),sessionPath);
   140 	test_KErrNone(r);
   134 	test(r==KErrNone);
   141 	RecursiveRmDir(sessionPath.FullName());
   135 	RecursiveRmDir(sessionPath.FullName());
   142 	r=TheFs.MkDir(sessionPath.FullName());
   136 	r=TheFs.MkDir(sessionPath.FullName());
   143 	test_KErrNone(r);
   137 	test(r==KErrNone);
   144 	}
   138 	}
   145 
   139 
   146 
   140 
   147 static void DoTestFileRead(TInt aBlockSize, TInt aFileSize = KMaxFileSize, TBool aReRead = EFalse)
   141 LOCAL_C void DoTestFileRead(TInt aBlockSize, TInt aFileSize = KMaxFileSize, TBool aReRead = EFalse)
   148 //
   142 //
   149 // Do Read Test
   143 // Do Read Test
   150 //
   144 //
   151 	{
   145 	{
   152 	// Create test data
   146 	// Create test data
   158 		DataBuf[m] = TText8(m % 256);
   152 		DataBuf[m] = TText8(m % 256);
   159 #endif
   153 #endif
   160 	// To allow this test to run on a non-preq914 branch :
   154 	// To allow this test to run on a non-preq914 branch :
   161 	enum {EFileWriteDirectIO = 0x00001000};
   155 	enum {EFileWriteDirectIO = 0x00001000};
   162 	TInt r = File.Create(TheFs, _L("READTEST"), EFileStream | EFileWriteDirectIO);
   156 	TInt r = File.Create(TheFs, _L("READTEST"), EFileStream | EFileWriteDirectIO);
   163 	test_KErrNone(r);
   157 	test(r == KErrNone);
   164 	TInt count = aFileSize / DataBuf.Length();
   158 	TInt count = aFileSize / DataBuf.Length();
   165 	while (count--)
   159 	while (count--)
   166 		File.Write(DataBuf);
   160 		File.Write(DataBuf);
   167 //	test.Printf(_L("done\n"));
   161 //	test.Printf(_L("done\n"));
   168 	File.Close();
   162 	File.Close();
   169 
   163 
   170 	enum {EFileReadBuffered = 0x00002000, EFileReadDirectIO = 0x00004000};
   164 	enum {EFileReadBuffered = 0x00002000, EFileReadDirectIO = 0x00004000};
   171 	r = File.Open(TheFs, _L("READTEST"), EFileStream | (gReadCachingOn ? EFileReadBuffered : EFileReadDirectIO));
   165 	r = File.Open(TheFs, _L("READTEST"), EFileStream | (gReadCachingOn ? EFileReadBuffered : EFileReadDirectIO));
   172 	test_KErrNone(r);
   166 	test(r == KErrNone);
   173 
   167 
   174 //	const TInt maxReadCount = aFileSize / aBlockSize;
   168 //	const TInt maxReadCount = aFileSize / aBlockSize;
   175 	TUint functionCalls = 0;
   169 	TUint functionCalls = 0;
   176 
   170 
   177 #if defined SYMBIAN_TEST_COPY
   171 #if defined SYMBIAN_TEST_COPY
   178 	// To allow this test to run on a non-preq914 branch :
   172 	// To allow this test to run on a non-preq914 branch :
   179 	enum {EFileWriteDirectIO = 0x00001000};
   173 	enum {EFileWriteDirectIO = 0x00001000};
   180 	TInt r = File2.Replace(TheFs, _L("WRITETEST"), EFileStream | EFileWriteDirectIO);
   174 	TInt r = File2.Replace(TheFs, _L("WRITETEST"), EFileStream | EFileWriteDirectIO);
   181 	test_KErrNone(r);
   175 	test(r == KErrNone);
   182 #endif
   176 #endif
   183 
   177 
   184 	TTime startTime(0);
   178 	TTime startTime(0);
   185 	TTime endTime(0);
   179 	TTime endTime(0);
   186 
   180 
   213 //			test.Printf(_L("Read %d\n"),i);
   207 //			test.Printf(_L("Read %d\n"),i);
   214 //			for (TInt a = 0; a < 512; a++)
   208 //			for (TInt a = 0; a < 512; a++)
   215 //				test.Printf(_L("%d"),DataBuf[a]);
   209 //				test.Printf(_L("%d"),DataBuf[a]);
   216 
   210 
   217 			TInt r = File.Read(DataBuf, readLen);
   211 			TInt r = File.Read(DataBuf, readLen);
   218 			test_KErrNone(r);
   212 			test (r == KErrNone);
   219 
   213 
   220 			if (DataBuf.Length() == 0)
   214 			if (DataBuf.Length() == 0)
   221 				break;
   215 				break;
   222 
   216 
   223 #if defined SYMBIAN_TEST_COPY
   217 #if defined SYMBIAN_TEST_COPY
   224 			r = File2.Write(DataBuf, readLen);
   218 			r = File2.Write(DataBuf, readLen);
   225 			test_KErrNone(r);
   219 			test (r == KErrNone);
   226 #endif
   220 #endif
   227 			functionCalls++;
   221 			functionCalls++;
   228 
   222 
   229 #if defined(_DEBUG)
   223 #if defined(_DEBUG)
   230 //			for (TInt a = 0; a < 512; a++)
   224 //			for (TInt a = 0; a < 512; a++)
   258 	File2.Close();
   252 	File2.Close();
   259 #endif
   253 #endif
   260 
   254 
   261 	File.Close();
   255 	File.Close();
   262 	r = TheFs.Delete(_L("READTEST"));
   256 	r = TheFs.Delete(_L("READTEST"));
   263 	test_KErrNone(r);
   257 	test(r == KErrNone);
   264 	return;
   258 	return;
   265 	}
   259 	}
   266 
   260 
   267 
   261 
   268 static void TestFileRead(TInt aFileSize = KMaxFileSize, TBool aMisalignedReadWrites = EFalse, TBool aReRead = EFalse)
   262 LOCAL_C void TestFileRead(TInt aFileSize = KMaxFileSize, TBool aMisalignedReadWrites = EFalse, TBool aReRead = EFalse)
   269 //
   263 //
   270 // Benchmark read method
   264 // Benchmark read method
   271 //
   265 //
   272 	{
   266 	{
   273 	ClearSessionDirectory();
   267 	ClearSessionDirectory();
   296 	DoTestFileRead(16 * 1024+misalignedOffset, aFileSize, aReRead);
   290 	DoTestFileRead(16 * 1024+misalignedOffset, aFileSize, aReRead);
   297 	DoTestFileRead(32 * 1024+misalignedOffset, aFileSize, aReRead);
   291 	DoTestFileRead(32 * 1024+misalignedOffset, aFileSize, aReRead);
   298 	DoTestFileRead(64 * 1024+misalignedOffset, aFileSize, aReRead);
   292 	DoTestFileRead(64 * 1024+misalignedOffset, aFileSize, aReRead);
   299 	DoTestFileRead(128 * 1024+misalignedOffset, aFileSize, aReRead);
   293 	DoTestFileRead(128 * 1024+misalignedOffset, aFileSize, aReRead);
   300 	DoTestFileRead(256 * 1024+misalignedOffset, aFileSize, aReRead);
   294 	DoTestFileRead(256 * 1024+misalignedOffset, aFileSize, aReRead);
   301 #ifndef __WINS__	// Block sizes are too large for the emulator
       
   302 	DoTestFileRead(512 * 1024+misalignedOffset, aFileSize, aReRead);
   295 	DoTestFileRead(512 * 1024+misalignedOffset, aFileSize, aReRead);
   303 	DoTestFileRead(1024 * 1024+misalignedOffset, aFileSize, aReRead);
   296 	DoTestFileRead(1024 * 1024+misalignedOffset, aFileSize, aReRead);
   304 #endif
       
   305 #else
   297 #else
   306 	DoTestFileRead(16+misalignedOffset, aFileSize, aReRead);
   298 	DoTestFileRead(16+misalignedOffset, aFileSize, aReRead);
   307 	DoTestFileRead(512+misalignedOffset, aFileSize, aReRead);
   299 	DoTestFileRead(512+misalignedOffset, aFileSize, aReRead);
   308 	DoTestFileRead(4096+misalignedOffset, aFileSize, aReRead);
   300 	DoTestFileRead(4096+misalignedOffset, aFileSize, aReRead);
   309 	DoTestFileRead(32768+misalignedOffset, aFileSize, aReRead);
   301 	DoTestFileRead(32768+misalignedOffset, aFileSize, aReRead);
   312 #endif
   304 #endif
   313 
   305 
   314 	}
   306 	}
   315 
   307 
   316 
   308 
   317 static TInt FloatingPointLoop(TAny* funcCount)
   309 LOCAL_C TInt FloatingPointLoop(TAny* funcCount)
   318 	{
   310 	{
   319 	TUint& count = *(TUint*) funcCount;
   311 	TUint& count = *(TUint*) funcCount;
   320 	TReal eq = KPi;
   312 	TReal eq = KPi;
   321 
   313 
   322 	FOREVER
   314 	FOREVER
   326 		}
   318 		}
   327 
   319 
   328 	}
   320 	}
   329 
   321 
   330 
   322 
   331 static void DoTestFileReadCPU(TInt aBlockSize)
   323 LOCAL_C void DoTestFileReadCPU(TInt aBlockSize)
   332 //
   324 //
   333 // Benchmark CPU utilisation for Read method
   325 // Benchmark CPU utilisation for Read method
   334 //
   326 //
   335 // Read operations are performed for 10 seconds whilst a second thread executes floating point calculations
   327 // Read operations are performed for 10 seconds whilst a second thread executes floating point calculations
   336 // The higher the number of calculations the less amount of CPU time has been used by the Read method.
   328 // The higher the number of calculations the less amount of CPU time has been used by the Read method.
   337 //
   329 //
   338 	{
   330 	{
   339 	enum {EFileReadBuffered = 0x00002000, EFileReadDirectIO = 0x00004000};
   331 	enum {EFileReadBuffered = 0x00002000, EFileReadDirectIO = 0x00004000};
   340 	TInt r = File.Open(TheFs, _L("READCPUTEST"), EFileStream | (gReadCachingOn ? EFileReadBuffered : EFileReadDirectIO));
   332 	TInt r = File.Open(TheFs, _L("READCPUTEST"), EFileStream | (gReadCachingOn ? EFileReadBuffered : EFileReadDirectIO));
   341 	test_KErrNone(r);
   333 	test(r == KErrNone);
   342 
   334 
   343 	TInt pos = 0;
   335 	TInt pos = 0;
   344 
   336 
   345 	TUint functionCalls = 0;
   337 	TUint functionCalls = 0;
   346 	TUint fltPntCalls = 0;
   338 	TUint fltPntCalls = 0;
   369 	fltPntThrd.Resume();
   361 	fltPntThrd.Resume();
   370 
   362 
   371 	for (TInt i = 0; reqStat==KRequestPending; i++)
   363 	for (TInt i = 0; reqStat==KRequestPending; i++)
   372 		{
   364 		{
   373 		TInt r = File.Read(pos, DataBuf, aBlockSize);
   365 		TInt r = File.Read(pos, DataBuf, aBlockSize);
   374 		test_KErrNone(r);
   366 		test (r == KErrNone);
   375 
   367 
   376 		pos += aBlockSize;
   368 		pos += aBlockSize;
   377 		if (pos > KMaxFileSize-aBlockSize)
   369 		if (pos > KMaxFileSize-aBlockSize)
   378 			pos = 0;
   370 			pos = 0;
   379 
   371 
   404 
   396 
   405 	return;
   397 	return;
   406 	}
   398 	}
   407 
   399 
   408 
   400 
   409 static void TestFileReadCPU(TBool aMisalignedReadWrites = EFalse)
   401 LOCAL_C void TestFileReadCPU(TBool aMisalignedReadWrites = EFalse)
   410 //
   402 //
   411 // Benchmark CPU utilisation for Read method
   403 // Benchmark CPU utilisation for Read method
   412 //
   404 //
   413 	{
   405 	{
   414 	ClearSessionDirectory();
   406 	ClearSessionDirectory();
   420 	// Create test data
   412 	// Create test data
   421 	test.Printf(_L("Creating test file..."));
   413 	test.Printf(_L("Creating test file..."));
   422 	DataBuf.SetLength(KMaxFileSize);
   414 	DataBuf.SetLength(KMaxFileSize);
   423 
   415 
   424 	TInt r = File.Create(TheFs, _L("READCPUTEST"), EFileStream | EFileWriteDirectIO);
   416 	TInt r = File.Create(TheFs, _L("READCPUTEST"), EFileStream | EFileWriteDirectIO);
   425 	test_KErrNone(r);
   417 	test(r == KErrNone);
   426 
   418 
   427 	File.Write(DataBuf);
   419 	File.Write(DataBuf);
   428 
   420 
   429 	test.Printf(_L("done\n"));
   421 	test.Printf(_L("done\n"));
   430 	File.Close();
   422 	File.Close();
   446 	DoTestFileReadCPU(16 * 1024+misalignedOffset);
   438 	DoTestFileReadCPU(16 * 1024+misalignedOffset);
   447 	DoTestFileReadCPU(32 * 1024+misalignedOffset);
   439 	DoTestFileReadCPU(32 * 1024+misalignedOffset);
   448 	DoTestFileReadCPU(64 * 1024+misalignedOffset);
   440 	DoTestFileReadCPU(64 * 1024+misalignedOffset);
   449 	DoTestFileReadCPU(128 * 1024+misalignedOffset);
   441 	DoTestFileReadCPU(128 * 1024+misalignedOffset);
   450 	DoTestFileReadCPU(256 * 1024+misalignedOffset);
   442 	DoTestFileReadCPU(256 * 1024+misalignedOffset);
   451 #ifndef __WINS__	// Block sizes are too large for the emulator
       
   452 	DoTestFileReadCPU(512 * 1024+misalignedOffset);
   443 	DoTestFileReadCPU(512 * 1024+misalignedOffset);
   453 	DoTestFileReadCPU(K1M+misalignedOffset);
   444 	DoTestFileReadCPU(K1M+misalignedOffset);
   454 #endif
   445 
   455 
   446 
   456 	r = TheFs.Delete(_L("READCPUTEST"));
   447 	r = TheFs.Delete(_L("READCPUTEST"));
   457 	test_KErrNone(r);
   448 	test(r == KErrNone);
   458 	}
   449 	}
   459 
   450 
   460 
   451 
   461 static void DoTestFileWrite(TInt aBlockSize, TInt aFileSize = KMaxFileSize, TBool aUpdate = EFalse)
   452 LOCAL_C void DoTestFileWrite(TInt aBlockSize, TInt aFileSize = KMaxFileSize, TBool aUpdate = EFalse)
   462 //
   453 //
   463 // Do Write benchmark
   454 // Do Write benchmark
   464 //
   455 //
   465 	{
   456 	{
   466 	DataBuf.SetLength(aBlockSize);
   457 	DataBuf.SetLength(aBlockSize);
   467 	const TInt maxWriteCount = aFileSize / aBlockSize;
   458 	const TInt maxWriteCount = aFileSize / aBlockSize;
   468 
   459 
   469 	TFileName testDir(_L("?:\\F32-TST\\"));
   460 	TFileName testDir(_L("?:\\F32-TST\\"));
   470 	testDir[0] = (TText) gDriveToTest;
   461 	testDir[0] = (TText) gDriveToTest;
   471 	TInt r = TheFs.MkDir(testDir);
   462 	TInt r = TheFs.MkDir(testDir);
   472 	test_Value(r, r == KErrNone || r == KErrAlreadyExists);
   463 	test(r == KErrNone || r == KErrAlreadyExists);
   473 
   464 
   474 	TFileName fileName;
   465 	TFileName fileName;
   475 	r = File.Temp(TheFs, testDir, fileName, EFileWrite | (gFileSequentialModeOn ? EFileSequential : 0) 
   466 	enum {EFileWriteDirectIO = 0x00001000, EFileWriteBuffered = 0x00000800};
   476 											| (gWriteCachingOn ? EFileWriteBuffered : EFileWriteDirectIO));
   467 	r = File.Temp(TheFs, testDir, fileName, EFileWrite | (gWriteCachingOn ? EFileWriteBuffered : EFileWriteDirectIO));
   477 	test_KErrNone(r);
   468 	test(r == KErrNone);
   478 
   469 
   479 	if (aUpdate)
   470 	if (aUpdate)
   480 		{
   471 		{
   481 		TInt r = File.SetSize(aFileSize);
   472 		TInt r = File.SetSize(aFileSize);
   482 		test_KErrNone(r);
   473 		test(r == KErrNone);
   483 		}
   474 		}
   484 
   475 
   485 	TUint functionCalls = 0;
   476 	TUint functionCalls = 0;
   486 
   477 
   487 	TTime startTime;
   478 	TTime startTime;
   541 
   532 
   542 	return;
   533 	return;
   543 	}
   534 	}
   544 
   535 
   545 
   536 
   546 static void TestFileWrite(TInt aFileSize = KMaxFileSize, TBool aMisalignedReadWrites = EFalse, TBool aUpdate = EFalse)
   537 LOCAL_C void TestFileWrite(TInt aFileSize = KMaxFileSize, TBool aMisalignedReadWrites = EFalse, TBool aUpdate = EFalse)
   547 //
   538 //
   548 // Benchmark write method
   539 // Benchmark write method
   549 //
   540 //
   550 	{
   541 	{
   551 	ClearSessionDirectory();
   542 	ClearSessionDirectory();
   575 	DoTestFileWrite(16 * 1024+misalignedOffset, aFileSize, aUpdate);
   566 	DoTestFileWrite(16 * 1024+misalignedOffset, aFileSize, aUpdate);
   576 	DoTestFileWrite(32 * 1024+misalignedOffset, aFileSize, aUpdate);
   567 	DoTestFileWrite(32 * 1024+misalignedOffset, aFileSize, aUpdate);
   577 	DoTestFileWrite(64 * 1024+misalignedOffset, aFileSize, aUpdate);
   568 	DoTestFileWrite(64 * 1024+misalignedOffset, aFileSize, aUpdate);
   578 	DoTestFileWrite(128 * 1024+misalignedOffset, aFileSize, aUpdate);
   569 	DoTestFileWrite(128 * 1024+misalignedOffset, aFileSize, aUpdate);
   579 	DoTestFileWrite(256 * 1024+misalignedOffset, aFileSize, aUpdate);
   570 	DoTestFileWrite(256 * 1024+misalignedOffset, aFileSize, aUpdate);
   580 #ifndef __WINS__	// Block sizes are too large for the emulator
       
   581 	DoTestFileWrite(512 * 1024+misalignedOffset, aFileSize, aUpdate);
   571 	DoTestFileWrite(512 * 1024+misalignedOffset, aFileSize, aUpdate);
   582 	DoTestFileWrite(1024 * 1024+misalignedOffset, aFileSize, aUpdate);
   572 	DoTestFileWrite(1024 * 1024+misalignedOffset, aFileSize, aUpdate);
   583 #endif
       
   584 #else
   573 #else
   585 	DoTestFileWrite(16+misalignedOffset, aFileSize, aUpdate);
   574 	DoTestFileWrite(16+misalignedOffset, aFileSize, aUpdate);
   586 	DoTestFileWrite(512+misalignedOffset, aFileSize, aUpdate);
   575 	DoTestFileWrite(512+misalignedOffset, aFileSize, aUpdate);
   587 	DoTestFileWrite(4096+misalignedOffset, aFileSize, aUpdate);
   576 	DoTestFileWrite(4096+misalignedOffset, aFileSize, aUpdate);
   588 	DoTestFileWrite(32768+misalignedOffset, aFileSize, aUpdate);
   577 	DoTestFileWrite(32768+misalignedOffset, aFileSize, aUpdate);
   591 #endif
   580 #endif
   592 	}
   581 	}
   593 
   582 
   594 
   583 
   595 
   584 
   596 static void DoTestFileWriteCPU(TInt aBlockSize)
   585 LOCAL_C void DoTestFileWriteCPU(TInt aBlockSize)
   597 //
   586 //
   598 // Benchmark CPU utilisation for Write method
   587 // Benchmark CPU utilisation for Write method
   599 //
   588 //
   600 // Write operations are performed for 10 seconds whilst a second thread executes floating point calculations
   589 // Write operations are performed for 10 seconds whilst a second thread executes floating point calculations
   601 // The higher the number of calculations the less amount of CPU time has been used by the Write method.
   590 // The higher the number of calculations the less amount of CPU time has been used by the Write method.
   604 	DataBuf.SetLength(aBlockSize);
   593 	DataBuf.SetLength(aBlockSize);
   605 
   594 
   606 	TFileName testDir(_L("?:\\F32-TST\\"));
   595 	TFileName testDir(_L("?:\\F32-TST\\"));
   607 	testDir[0] = (TText) gDriveToTest;
   596 	testDir[0] = (TText) gDriveToTest;
   608 	TInt r = TheFs.MkDir(testDir);
   597 	TInt r = TheFs.MkDir(testDir);
   609 	test_Value(r, r == KErrNone || r == KErrAlreadyExists);
   598 	test(r == KErrNone || r == KErrAlreadyExists);
   610 
   599 
   611 	TFileName fileName;
   600 	TFileName fileName;
   612 	r = File.Temp(TheFs, testDir, fileName, EFileWrite | (gFileSequentialModeOn ? EFileSequential : 0)
   601 	enum {EFileWriteDirectIO = 0x00001000, EFileWriteBuffered = 0x00000800};
   613 											| (gWriteCachingOn ? EFileWriteBuffered : EFileWriteDirectIO));
   602 	r = File.Temp(TheFs, testDir, fileName, EFileWrite | (gWriteCachingOn ? EFileWriteBuffered : EFileWriteDirectIO));
   614 	test_KErrNone(r);
   603 	test(r == KErrNone);
   615 
   604 
   616 	TUint functionCalls = 0;
   605 	TUint functionCalls = 0;
   617 	TUint fltPntCalls = 0;
   606 	TUint fltPntCalls = 0;
   618 	RThread fltPntThrd;
   607 	RThread fltPntThrd;
   619 
   608 
   673 
   662 
   674 	return;
   663 	return;
   675 	}
   664 	}
   676 
   665 
   677 
   666 
   678 static void TestFileWriteCPU(TBool aMisalignedReadWrites = EFalse)
   667 LOCAL_C void TestFileWriteCPU(TBool aMisalignedReadWrites = EFalse)
   679 //
   668 //
   680 // Benchmark CPU utilisation for Write method
   669 // Benchmark CPU utilisation for Write method
   681 //
   670 //
   682 	{
   671 	{
   683 	ClearSessionDirectory();
   672 	ClearSessionDirectory();
   703 	DoTestFileWriteCPU(16 * 1024+misalignedOffset);
   692 	DoTestFileWriteCPU(16 * 1024+misalignedOffset);
   704 	DoTestFileWriteCPU(32 * 1024+misalignedOffset);
   693 	DoTestFileWriteCPU(32 * 1024+misalignedOffset);
   705 	DoTestFileWriteCPU(64 * 1024+misalignedOffset);
   694 	DoTestFileWriteCPU(64 * 1024+misalignedOffset);
   706 	DoTestFileWriteCPU(128 * 1024+misalignedOffset);
   695 	DoTestFileWriteCPU(128 * 1024+misalignedOffset);
   707 	DoTestFileWriteCPU(256 * 1024+misalignedOffset);
   696 	DoTestFileWriteCPU(256 * 1024+misalignedOffset);
   708 #ifndef __WINS__	// Block sizes are too large for the emulator
       
   709 	DoTestFileWriteCPU(512 * 1024+misalignedOffset);
   697 	DoTestFileWriteCPU(512 * 1024+misalignedOffset);
   710 	DoTestFileWriteCPU(K1M+misalignedOffset);
   698 	DoTestFileWriteCPU(K1M+misalignedOffset);
   711 #endif
   699 	}
   712 	}
   700 
   713 
   701 
   714 
   702 LOCAL_C void TestFileSeek()
   715 static void TestFileSeek()
       
   716 //
   703 //
   717 // Benchmark file seek method
   704 // Benchmark file seek method
   718 //
   705 //
   719 	{
   706 	{
   720 	ClearSessionDirectory();
   707 	ClearSessionDirectory();
   725 
   712 
   726 	// Create test file
   713 	// Create test file
   727 	TBuf8<1024> testdata(1024);
   714 	TBuf8<1024> testdata(1024);
   728 	RFile f;
   715 	RFile f;
   729 	TInt r=f.Create(TheFs,_L("SEEKTEST"),EFileStream);
   716 	TInt r=f.Create(TheFs,_L("SEEKTEST"),EFileStream);
   730 	test_KErrNone(r);
   717 	test(r==KErrNone);
   731 	count=64;
   718 	count=64;
   732 	while (count--)
   719 	while (count--)
   733 		f.Write(testdata);
   720 		f.Write(testdata);
   734 	TInt fileSize=count*testdata.MaxLength();
   721 	TInt fileSize=count*testdata.MaxLength();
   735 
   722 
   752 	TheFs.Delete(_L("SEEKTEST"));
   739 	TheFs.Delete(_L("SEEKTEST"));
   753 	}
   740 	}
   754 
   741 
   755 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   742 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   756 
   743 
   757 static void CreateManyLargFiles(TInt aNumber)
   744 LOCAL_C void CreateManyLargFiles(TInt aNumber)
   758 //
   745 //
   759 // Make a directory with aNumber entries
   746 // Make a directory with aNumber entries
   760 //
   747 //
   761 	{
   748 	{
   762 	RFile64 f;
   749 	RFile64 f;
   764 
   751 
   765 	test.Printf(_L("Create a directory with %d entries\n"),aNumber);
   752 	test.Printf(_L("Create a directory with %d entries\n"),aNumber);
   766 
   753 
   767 	TFileName sessionPath;
   754 	TFileName sessionPath;
   768 	TInt r=TheFs.SessionPath(sessionPath);
   755 	TInt r=TheFs.SessionPath(sessionPath);
   769 	test_KErrNone(r);
   756 	test(r==KErrNone);
   770 	r=TheFs.MkDir(_L("\\F32-TST\\"));
   757 	r=TheFs.MkDir(_L("\\F32-TST\\"));
   771 	test((r==KErrNone)||(r==KErrAlreadyExists));
   758 	test((r==KErrNone)||(r==KErrAlreadyExists));
   772 	r=TheFs.MkDir(_L("\\F32-TST\\BENCH_DELETE\\"));
   759 	r=TheFs.MkDir(_L("\\F32-TST\\BENCH_DELETE\\"));
   773 	test((r==KErrNone)||(r==KErrAlreadyExists));
   760 	test((r==KErrNone)||(r==KErrAlreadyExists));
   774 	TBuf8<8> WriteData =_L8("Wibbleuy");
   761 	TBuf8<8> WriteData =_L8("Wibbleuy");
   775 	for (TInt i=0;i<maxEntry;i++)
   762 	for (TInt i=0;i<maxEntry;i++)
   776 		{
   763 		{
   777 		TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
   764 		TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
   778 		baseName.AppendNum(i);
   765 		baseName.AppendNum(i);
   779 		r=f.Replace(TheFs,baseName,EFileWrite);
   766 		r=f.Replace(TheFs,baseName,EFileWrite);
   780 		test_KErrNone(r);
   767 		test(r==KErrNone);
   781 		r = f.SetSize(K3GB);
   768 		r = f.SetSize(K3GB);
   782 		test_KErrNone(r);
   769 		test(r==KErrNone);
   783 		r=f.Write((K3GB-30),WriteData);
   770 		r=f.Write((K3GB-30),WriteData);
   784 		test_KErrNone(r);
   771 		test(r==KErrNone);
   785 		f.Flush();
   772 		f.Flush();
   786 		f.Close();
   773 		f.Close();
   787 		}
   774 		}
   788 
   775 
   789 	test.Printf(_L("Test all entries have been created successfully\n"));
   776 	test.Printf(_L("Test all entries have been created successfully\n"));
   795 		baseName.AppendNum(j);
   782 		baseName.AppendNum(j);
   796 
   783 
   797 		TInt r=f.Open(TheFs,baseName,EFileRead);
   784 		TInt r=f.Open(TheFs,baseName,EFileRead);
   798 		if (r!=KErrNone)
   785 		if (r!=KErrNone)
   799 			{
   786 			{
   800 			test_Value(r, r == KErrNotFound && j==maxEntry);
   787 			test(r==KErrNotFound && j==maxEntry);
   801 			return;
   788 			return;
   802 			}
   789 			}
   803 		ReadData.FillZ();
   790 		ReadData.FillZ();
   804 		r=f.Read((K3GB-30),ReadData);
   791 		r=f.Read((K3GB-30),ReadData);
   805 		test_KErrNone(r);
   792 		test(r==KErrNone);
   806 		test(f.Size(Size)==KErrNone);
   793 		test(f.Size(Size)==KErrNone);
   807 		test(K3GB == Size);
   794 		test(K3GB == Size);
   808 		test(ReadData==WriteData);
   795 		test(ReadData==WriteData);
   809 		f.Close();
   796 		f.Close();
   810 		}
   797 		}
   811 	}
   798 	}
   812 
   799 
   813 
   800 
   814 static void TestLargeFileDelete()
   801 LOCAL_C void TestLargeFileDelete()
   815 //
   802 //
   816 // This test require MMC/SD card size >=4GB-2 in size
   803 // This test require MMC/SD card size >=4GB-2 in size
   817 //
   804 //
   818 	{
   805 	{
   819 	ClearSessionDirectory();
   806 	ClearSessionDirectory();
   828 	//check Disk space and decide how many files to create
   815 	//check Disk space and decide how many files to create
   829 	TVolumeInfo volInfo;
   816 	TVolumeInfo volInfo;
   830     TInt r;
   817     TInt r;
   831 
   818 
   832     r = TheFs.Volume(volInfo);
   819     r = TheFs.Volume(volInfo);
   833     test_KErrNone(r);
   820     test(r == KErrNone);
   834     
   821 
   835 	TInt numberOfFiles = (TUint)(volInfo.iFree/(K4GB -2));
   822 	TInt numberOfFiles = (TUint)(volInfo.iFree/(K4GB -2));
   836 #ifdef __WINS__
       
   837 	// Fix a maximum number of large files to create on the emulator
       
   838 	if (numberOfFiles > 5)
       
   839 		numberOfFiles = 5;
       
   840 #endif
       
   841 	test.Printf(_L("Number of large files =%d \n"),numberOfFiles);
   823 	test.Printf(_L("Number of large files =%d \n"),numberOfFiles);
   842 
   824 
   843 	if(numberOfFiles<=0)
   825 	if(numberOfFiles<=0)
   844 		{
   826 		{
   845 		test.Printf(_L("Large File delete is skipped \n"));
   827 		test.Printf(_L("Large File delete is skipped \n"));
   860 			{
   842 			{
   861 			TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
   843 			TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
   862 			baseName.AppendNum(index);
   844 			baseName.AppendNum(index);
   863 
   845 
   864 			TInt r=TheFs.Delete(baseName);
   846 			TInt r=TheFs.Delete(baseName);
   865 			test_KErrNone(r);
   847 			test(r==KErrNone);
   866 			}
   848 			}
   867 
   849 
   868 		TTime endTime;
   850 		TTime endTime;
   869 		endTime.HomeTime();
   851 		endTime.HomeTime();
   870 		TTimeIntervalMicroSeconds timeTaken;
   852 		TTimeIntervalMicroSeconds timeTaken;
   893 		startTime.HomeTime();
   875 		startTime.HomeTime();
   894 
   876 
   895 		for (TInt index=0;index<numberOfFiles;index++)
   877 		for (TInt index=0;index<numberOfFiles;index++)
   896 			{
   878 			{
   897 			TInt r=fMan->Delete(_L("\\F32-TST\\BENCH_DELETE\\FILE*"));
   879 			TInt r=fMan->Delete(_L("\\F32-TST\\BENCH_DELETE\\FILE*"));
   898 			test_Value(r, r == KErrNone || r==KErrNotFound);
   880 			test(r==KErrNone || r==KErrNotFound);
   899 			}
   881 			}
   900 
   882 
   901 		TTime endTime;
   883 		TTime endTime;
   902 		endTime.HomeTime();
   884 		endTime.HomeTime();
   903 		TTimeIntervalMicroSeconds timeTaken;
   885 		TTimeIntervalMicroSeconds timeTaken;
   914 }
   896 }
   915 
   897 
   916 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   898 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   917 
   899 
   918 
   900 
   919 static void CreateManyFiles(TInt aNumber)
   901 LOCAL_C void CreateManyFiles(TInt aNumber)
   920 //
   902 //
   921 // Make a directory with aNumber entries
   903 // Make a directory with aNumber entries
   922 //
   904 //
   923 	{
   905 	{
   924 	RFile f;
   906 	RFile f;
   926 
   908 
   927 	test.Printf(_L("Create a directory with %d entries\n"),aNumber);
   909 	test.Printf(_L("Create a directory with %d entries\n"),aNumber);
   928 
   910 
   929 	TFileName sessionPath;
   911 	TFileName sessionPath;
   930 	TInt r=TheFs.SessionPath(sessionPath);
   912 	TInt r=TheFs.SessionPath(sessionPath);
   931 	test_KErrNone(r);
   913 	test(r==KErrNone);
   932 	r=TheFs.MkDir(_L("\\F32-TST\\"));
   914 	r=TheFs.MkDir(_L("\\F32-TST\\"));
   933 	test((r==KErrNone)||(r==KErrAlreadyExists));
   915 	test((r==KErrNone)||(r==KErrAlreadyExists));
   934 	r=TheFs.MkDir(_L("\\F32-TST\\BENCH_DELETE\\"));
   916 	r=TheFs.MkDir(_L("\\F32-TST\\BENCH_DELETE\\"));
   935 	test((r==KErrNone)||(r==KErrAlreadyExists));
   917 	test((r==KErrNone)||(r==KErrAlreadyExists));
   936 
   918 
   937 	for (TInt i=0;i<maxEntry;i++)
   919 	for (TInt i=0;i<maxEntry;i++)
   938 		{
   920 		{
   939 		TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
   921 		TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
   940 		baseName.AppendNum(i);
   922 		baseName.AppendNum(i);
   941 		r=f.Replace(TheFs,baseName,EFileRead);
   923 		r=f.Replace(TheFs,baseName,EFileRead);
   942 		test_KErrNone(r);
   924 		test(r==KErrNone);
   943 		r=f.Write(_L8("Wibble"));
   925 		r=f.Write(_L8("Wibble"));
   944 		test_KErrNone(r);
   926 		test(r==KErrNone);
   945 		f.Close();
   927 		f.Close();
   946 		}
   928 		}
   947 
   929 
   948 	test.Printf(_L("Test all entries have been created successfully\n"));
   930 	test.Printf(_L("Test all entries have been created successfully\n"));
   949 	for (TInt j=0;j<=maxEntry;j++)
   931 	for (TInt j=0;j<=maxEntry;j++)
   951 		TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
   933 		TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
   952 		baseName.AppendNum(j);
   934 		baseName.AppendNum(j);
   953 		TInt r=f.Open(TheFs,baseName,EFileRead);
   935 		TInt r=f.Open(TheFs,baseName,EFileRead);
   954 		if (r!=KErrNone)
   936 		if (r!=KErrNone)
   955 			{
   937 			{
   956 			test_Value(r, r == KErrNotFound && j==maxEntry);
   938 			test(r==KErrNotFound && j==maxEntry);
   957 			return;
   939 			return;
   958 			}
   940 			}
   959 		TBuf8<16> data;
   941 		TBuf8<16> data;
   960 		r=f.Read(data);
   942 		r=f.Read(data);
   961 		test_KErrNone(r);
   943 		test(r==KErrNone);
   962 		test(data==_L8("Wibble"));
   944 		test(data==_L8("Wibble"));
   963 		f.Close();
   945 		f.Close();
   964 		}
   946 		}
   965 	}
   947 	}
   966 
   948 
   967 
   949 
   968 static void TestFileDelete()
   950 LOCAL_C void TestFileDelete()
   969 //
   951 //
   970 //
   952 //
   971 //
   953 //
   972 	{
   954 	{
   973 	ClearSessionDirectory();
   955 	ClearSessionDirectory();
   992 			{
   974 			{
   993 			TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
   975 			TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
   994 			baseName.AppendNum(index);
   976 			baseName.AppendNum(index);
   995 
   977 
   996 			TInt r=TheFs.Delete(baseName);
   978 			TInt r=TheFs.Delete(baseName);
   997 			test_KErrNone(r);
   979 			test(r==KErrNone);
   998 			}
   980 			}
   999 
   981 
  1000 		TTime endTime;
   982 		TTime endTime;
  1001 		endTime.HomeTime();
   983 		endTime.HomeTime();
  1002 		TTimeIntervalMicroSeconds timeTaken;
   984 		TTimeIntervalMicroSeconds timeTaken;
  1025 		startTime.HomeTime();
  1007 		startTime.HomeTime();
  1026 
  1008 
  1027 		for (TInt index=0;index<numberOfFiles;index++)
  1009 		for (TInt index=0;index<numberOfFiles;index++)
  1028 			{
  1010 			{
  1029 			TInt r=fMan->Delete(_L("\\F32-TST\\BENCH_DELETE\\FILE*"));
  1011 			TInt r=fMan->Delete(_L("\\F32-TST\\BENCH_DELETE\\FILE*"));
  1030 			test_Value(r, r == KErrNone || r==KErrNotFound);
  1012 			test(r==KErrNone || r==KErrNotFound);
  1031 			}
  1013 			}
  1032 
  1014 
  1033 		TTime endTime;
  1015 		TTime endTime;
  1034 		endTime.HomeTime();
  1016 		endTime.HomeTime();
  1035 		TTimeIntervalMicroSeconds timeTaken;
  1017 		TTimeIntervalMicroSeconds timeTaken;
  1046 }
  1028 }
  1047 
  1029 
  1048 
  1030 
  1049 /*
  1031 /*
  1050 TInt maxDirEntry=200;
  1032 TInt maxDirEntry=200;
  1051 static void TestDirRead()
  1033 LOCAL_C void TestDirRead()
  1052 //
  1034 //
  1053 // Benchmark directory read method
  1035 // Benchmark directory read method
  1054 //
  1036 //
  1055 	{
  1037 	{
  1056 
  1038 
  1096 	delete dirPtr;
  1078 	delete dirPtr;
  1097 	DirMatchOne=end.MicroSecondsFrom(start);
  1079 	DirMatchOne=end.MicroSecondsFrom(start);
  1098 	}
  1080 	}
  1099 
  1081 
  1100 
  1082 
  1101 void static PrintDirResults()
  1083 void LOCAL_C PrintDirResults()
  1102 //
  1084 //
  1103 // Print results of Directory Benchmark
  1085 // Print results of Directory Benchmark
  1104 //
  1086 //
  1105 	{
  1087 	{
  1106 	test.Printf(_L("\nBenchmark: Dir Results\n"));
  1088 	test.Printf(_L("\nBenchmark: Dir Results\n"));
  1111 	test.Getch();
  1093 	test.Getch();
  1112 	}
  1094 	}
  1113 */
  1095 */
  1114 
  1096 
  1115 
  1097 
  1116 static void TestMkDir()
  1098 LOCAL_C void TestMkDir()
  1117 	{
  1099 	{
  1118 	test.Next(_L("Benchmark MkDir"));
  1100 	test.Next(_L("Benchmark MkDir"));
  1119 	ClearSessionDirectory();
  1101 	ClearSessionDirectory();
  1120 
  1102 
  1121 	TTime startTime;
  1103 	TTime startTime;
  1128 		{
  1110 		{
  1129 		TFileName dirName = _L("\\F32-TST\\DIR_");
  1111 		TFileName dirName = _L("\\F32-TST\\DIR_");
  1130 		dirName.AppendNum(n);
  1112 		dirName.AppendNum(n);
  1131 		dirName.Append(_L("\\"));
  1113 		dirName.Append(_L("\\"));
  1132 		TInt r = TheFs.MkDir(dirName);
  1114 		TInt r = TheFs.MkDir(dirName);
  1133 		test_KErrNone(r);
  1115 		test(r == KErrNone);
  1134 		}
  1116 		}
  1135 
  1117 
  1136 	endTime.HomeTime();
  1118 	endTime.HomeTime();
  1137 	timeTaken=endTime.MicroSecondsFrom(startTime);
  1119 	timeTaken=endTime.MicroSecondsFrom(startTime);
  1138 	TInt timeTakenInMs = I64LOW(timeTaken.Int64() / 1000);
  1120 	TInt timeTakenInMs = I64LOW(timeTaken.Int64() / 1000);
  1154 		test(l.CancelLazyDllUnload()==KErrNone);
  1136 		test(l.CancelLazyDllUnload()==KErrNone);
  1155 		l.Close();
  1137 		l.Close();
  1156 
  1138 
  1157 		test.Printf(_L("Initialise\n"));
  1139 		test.Printf(_L("Initialise\n"));
  1158 		TInt r = UserHal::PageSizeInBytes(PageSize);
  1140 		TInt r = UserHal::PageSizeInBytes(PageSize);
  1159 		test_KErrNone(r);
  1141 		test(r==KErrNone);
  1160 
  1142 
  1161 		test.Printf(_L("Loading test driver\n"));
  1143 		test.Printf(_L("Loading test driver\n"));
  1162 		r = User::LoadLogicalDevice(KSharedChunkLddName);
  1144 		r = User::LoadLogicalDevice(KSharedChunkLddName);
  1163 		test_Value(r, r == KErrNone || r==KErrAlreadyExists);
  1145 		test(r==KErrNone || r==KErrAlreadyExists);
  1164 
  1146 
  1165 		test.Printf(_L("Opening channel\n"));
  1147 		test.Printf(_L("Opening channel\n"));
  1166 		r = Ldd.Open();
  1148 		r = Ldd.Open();
  1167 		test_KErrNone(r);
  1149 		test(r==KErrNone);
  1168 
  1150 
  1169 		test.Printf(_L("Create chunk\n"));
  1151 		test.Printf(_L("Create chunk\n"));
  1170 
  1152 
  1171 		TUint aCreateFlags = EMultiple|EOwnsMemory;
  1153 		TUint aCreateFlags = EMultiple|EOwnsMemory;
  1172 	    TCommitType aCommitType = EContiguous;
  1154 	    TCommitType aCommitType = EContiguous;
  1173 
  1155 
  1174 	    TUint TotalChunkSize = ChunkSize;  // rounded to nearest Page Size
  1156 	    TUint TotalChunkSize = ChunkSize;  // rounded to nearest Page Size
  1175 
  1157 
  1176 		TUint ChunkAttribs = TotalChunkSize|aCreateFlags;
  1158 		TUint ChunkAttribs = TotalChunkSize|aCreateFlags;
  1177 		r = Ldd.CreateChunk(ChunkAttribs);
  1159 		r = Ldd.CreateChunk(ChunkAttribs);
  1178 		test_KErrNone(r);
  1160 		test(r==KErrNone);
  1179 
  1161 
  1180 		if (gSharedMemory)
  1162 		if (gSharedMemory)
  1181 			{
  1163 			{
  1182 		    test.Printf(_L("Commit Contigouos Memory\n"));
  1164 		    test.Printf(_L("Commit Contigouos Memory\n"));
  1183 		    r = Ldd.CommitMemory(aCommitType,TotalChunkSize);
  1165 		    r = Ldd.CommitMemory(aCommitType,TotalChunkSize);
  1184 			test_KErrNone(r);
  1166 			test(r==KErrNone);
  1185 			}
  1167 			}
  1186 		else
  1168 		else
  1187 			{
  1169 			{
  1188 			test.Printf(_L("Commit Fragmented Memory\n"));
  1170 			test.Printf(_L("Commit Fragmented Memory\n"));
  1189 
  1171 
  1192 			do
  1174 			do
  1193 				{
  1175 				{
  1194 				i-=PageSize;
  1176 				i-=PageSize;
  1195 				test.Printf(_L("Commit %d\n"), i);
  1177 				test.Printf(_L("Commit %d\n"), i);
  1196 				r = Ldd.CommitMemory(aCommitType|i,PageSize);
  1178 				r = Ldd.CommitMemory(aCommitType|i,PageSize);
  1197 				test_KErrNone(r);
  1179 				test(r==KErrNone);
  1198 				}while (i>0);
  1180 				}while (i>0);
  1199 /*
  1181 /*
  1200 			for (TInt i = (ChunkSize-PageSize); i>=0; )
  1182 			for (TInt i = (ChunkSize-PageSize); i>=0; )
  1201 				{
  1183 				{
  1202 				test.Printf(_L("Commit %d\n"), i);
  1184 				test.Printf(_L("Commit %d\n"), i);
  1203 				r = Ldd.CommitMemory(aCommitType|i,PageSize);
  1185 				r = Ldd.CommitMemory(aCommitType|i,PageSize);
  1204 				test_KErrNone(r);
  1186 				test(r==KErrNone);
  1205 				i-=PageSize;
  1187 				i-=PageSize;
  1206 				}
  1188 				}
  1207 */
  1189 */
  1208 			}
  1190 			}
  1209 
  1191 
  1210 		test.Printf(_L("\nOpen user handle\n"));
  1192 		test.Printf(_L("\nOpen user handle\n"));
  1211 		r = Ldd.GetChunkHandle(TheChunk);
  1193 		r = Ldd.GetChunkHandle(TheChunk);
  1212 		test_KErrNone(r);
  1194 		test(r==KErrNone);
  1213 
  1195 
  1214 		DataBuf.Set(TheChunk.Base(),KMaxFileSize, KMaxFileSize);
  1196 		DataBuf.Set(TheChunk.Base(),KMaxFileSize, KMaxFileSize);
  1215 		}
  1197 		}
  1216 	else
  1198 	else
  1217 		{
  1199 		{
  1234 		test.Printf(_L("Close user chunk handle\n"));
  1216 		test.Printf(_L("Close user chunk handle\n"));
  1235 		TheChunk.Close();
  1217 		TheChunk.Close();
  1236 
  1218 
  1237 		test.Printf(_L("Close kernel chunk handle\n"));
  1219 		test.Printf(_L("Close kernel chunk handle\n"));
  1238 		TInt r = Ldd.CloseChunk();
  1220 		TInt r = Ldd.CloseChunk();
  1239 		test_Value(r, r == 1);
  1221 		test(r==1);
  1240 
  1222 
  1241 		test.Printf(_L("Check chunk is destroyed\n"));
  1223 		test.Printf(_L("Check chunk is destroyed\n"));
  1242 		r = Ldd.IsDestroyed();
  1224 		r = Ldd.IsDestroyed();
  1243 		test_Value(r, r == 1);
  1225 		test(r==1);
  1244 
  1226 
  1245 		test.Printf(_L("Close test driver\n"));
  1227 		test.Printf(_L("Close test driver\n"));
  1246 		Ldd.Close();
  1228 		Ldd.Close();
  1247 		}
  1229 		}
  1248 	else
  1230 	else
  1308 			continue;
  1290 			continue;
  1309 			}
  1291 			}
  1310 		if (token.CompareF(_L("+x"))== 0)
  1292 		if (token.CompareF(_L("+x"))== 0)
  1311 			{
  1293 			{
  1312 			gFragSharedMemory = ETrue;
  1294 			gFragSharedMemory = ETrue;
  1313 			continue;
       
  1314 			}
       
  1315 		
       
  1316 		if (token.CompareF(_L("+q"))== 0)
       
  1317 			{
       
  1318 			gFileSequentialModeOn = ETrue;
       
  1319 			continue;
       
  1320 			}
       
  1321 		if (token.CompareF(_L("-q"))== 0)
       
  1322 			{
       
  1323 			gFileSequentialModeOn = EFalse;
       
  1324 			continue;
  1295 			continue;
  1325 			}
  1296 			}
  1326 
  1297 
  1327 		test.Printf(_L("CLP=%S\n"),&token);
  1298 		test.Printf(_L("CLP=%S\n"),&token);
  1328 
  1299 
  1364 
  1335 
  1365 	AllocateBuffers();
  1336 	AllocateBuffers();
  1366 	RProcess().SetPriority(EPriorityBackground);
  1337 	RProcess().SetPriority(EPriorityBackground);
  1367 
  1338 
  1368 	TInt r = HAL::Get(HAL::EFastCounterFrequency, gFastCounterFreq);
  1339 	TInt r = HAL::Get(HAL::EFastCounterFrequency, gFastCounterFreq);
  1369 	test_KErrNone(r);
  1340 	test(r == KErrNone);
  1370 	test.Printf(_L("HAL::EFastCounterFrequency %d\n"), gFastCounterFreq);
  1341 	test.Printf(_L("HAL::EFastCounterFrequency %d\n"), gFastCounterFreq);
  1371 
  1342 
  1372 	test.Printf(_L("gReadCachingOn %d  gWriteCachingOn %d gFlushAfterWrite %d gFileSequentialModeOn %d\n"),
  1343 	test.Printf(_L("gReadCachingOn %d  gWriteCachingOn %d gFlushAfterWrite %d\n"), gReadCachingOn, gWriteCachingOn, gFlushAfterWrite);
  1373 				gReadCachingOn, gWriteCachingOn, gFlushAfterWrite, gFileSequentialModeOn);
       
  1374 
  1344 
  1375 	TestFileSeek();
  1345 	TestFileSeek();
  1376 
  1346 
  1377 	// read once
  1347 	// read once
  1378 	TestFileRead(KMaxFileSize, gMisalignedReadWrites, EFalse);
  1348 	TestFileRead(KMaxFileSize, gMisalignedReadWrites, EFalse);