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