0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// f32test/bench/t_fcachebm.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <f32file.h>
|
|
19 |
#include <e32test.h>
|
|
20 |
#include <e32math.h>
|
|
21 |
#include "t_select.h"
|
|
22 |
#include "t_benchmain.h"
|
|
23 |
|
|
24 |
//----------------------------------------------------------------------------------------------
|
|
25 |
//! @SYMTestCaseID PBASE-T_RCACHE-0192
|
|
26 |
//! @SYMTestType CIT
|
|
27 |
//! @SYMPREQ PREQ914
|
|
28 |
//! @SYMTestCaseDesc This test case is testing performance of the File Server Cache.
|
|
29 |
//! @SYMTestActions 0 setup the environment to execute the tests
|
|
30 |
//! 1 small random reads/writes
|
|
31 |
//! 2 large sequential reads/writes
|
|
32 |
//! 3 streaming test (100, 200 and 500 kbps)
|
|
33 |
//! @SYMTestExpectedResults Finishes if the system behaves as expected, panics otherwise
|
|
34 |
//! @SYMTestPriority High
|
|
35 |
//! @SYMTestStatus Implemented
|
|
36 |
//----------------------------------------------------------------------------------------------
|
|
37 |
|
|
38 |
|
|
39 |
GLDEF_D RTest test(_L("File Cache BM"));
|
|
40 |
|
|
41 |
LOCAL_D RSemaphore client;
|
|
42 |
LOCAL_D const TInt KHeapSize = 0x4000;
|
|
43 |
LOCAL_D const TInt KTobps = 1000;
|
|
44 |
LOCAL_D const TInt KByte = 8;
|
|
45 |
LOCAL_D const TInt KOneSec = 1000000; // One second in microseconds
|
|
46 |
|
|
47 |
// Tests setup
|
|
48 |
LOCAL_D const TInt KSmallRow = 11;
|
|
49 |
LOCAL_D const TInt KSmallCol = 7;
|
|
50 |
LOCAL_D const TInt KSmallThreshold = 64;
|
|
51 |
LOCAL_D const TInt KSeveralTimes = 10;
|
|
52 |
|
|
53 |
LOCAL_D const TInt KLargeRow = 19;
|
|
54 |
LOCAL_D const TInt KLargeCol = 3;
|
|
55 |
|
|
56 |
LOCAL_D TInt gCurrentSpeed = 0;
|
|
57 |
LOCAL_D TInt gCurrentBS = 0;
|
|
58 |
|
|
59 |
|
|
60 |
LOCAL_D TBuf8<4096> buf;
|
|
61 |
LOCAL_D TDriveList gDriveList;
|
|
62 |
|
|
63 |
// Concurrent thread
|
|
64 |
RThread gSpeedy;
|
|
65 |
RThread gSpeedyII;
|
|
66 |
|
|
67 |
TBuf16<25> gBaseFile;
|
|
68 |
TBuf16<25> gFileA;
|
|
69 |
TBuf16<25> gFileB;
|
|
70 |
TBuf16<25> gStreamFile;
|
|
71 |
|
|
72 |
HBufC8* gBuf = NULL;
|
|
73 |
TPtr8 gBufReadPtr(NULL, 0);
|
|
74 |
HBufC8* gBufSec = NULL;
|
|
75 |
TPtr8 gBufWritePtr(NULL, 0);
|
|
76 |
|
|
77 |
|
|
78 |
HBufC8* gBufB = NULL;
|
|
79 |
TPtr8 gBufReadBPtr(NULL, 0);
|
|
80 |
TBool gWriting = EFalse;
|
|
81 |
|
|
82 |
LOCAL_D TInt ThreadCount=0;
|
|
83 |
|
|
84 |
enum TTestState
|
|
85 |
{
|
|
86 |
ENoThreads, // No threads
|
|
87 |
ETwoThreadsDif, // Accessing to different files
|
|
88 |
ETwoThreadsDifDif, // Accessing to different files, different blocksizes
|
|
89 |
ETwoThreadsSame // Accessing the same file
|
|
90 |
};
|
|
91 |
|
|
92 |
|
|
93 |
/** 2 ^ b
|
|
94 |
|
|
95 |
@param b Power
|
|
96 |
*/
|
|
97 |
LOCAL_C TInt Pow(TInt b)
|
|
98 |
{
|
|
99 |
return 1 << b;
|
|
100 |
}
|
|
101 |
|
|
102 |
/** Pseudo-random number generator, random enough for the purpose
|
|
103 |
|
|
104 |
@param aMax Upper limit of the number. The interval of generated numbers is [0,aMax)
|
|
105 |
*/
|
|
106 |
LOCAL_C TInt Rand(TInt aMax)
|
|
107 |
{
|
|
108 |
return (Math::Random() % aMax);
|
|
109 |
}
|
|
110 |
|
|
111 |
|
|
112 |
/** Fills a buffer with character aC, aC+1, aC+2, ..., aC+32, aC, etc
|
|
113 |
|
|
114 |
@param aBuffer Buffer to fill out
|
|
115 |
@param aLength Length to be filled with characters
|
|
116 |
@param aC Base character to fill the buffer
|
|
117 |
*/
|
|
118 |
LOCAL_C void FillBuffer(TDes8& aBuffer, TInt aLength, TChar aC)
|
|
119 |
{
|
|
120 |
test (aBuffer.MaxLength() >= aLength);
|
|
121 |
|
|
122 |
for(TInt i = 0; i < aLength; i++)
|
|
123 |
{
|
|
124 |
aBuffer.Append((i%32)+aC);
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
/** Send content through the RDebug for trgtest
|
|
129 |
not to hung, when the test is not writing
|
|
130 |
|
|
131 |
*/
|
|
132 |
LOCAL_C TInt noise(TAny* )
|
|
133 |
{
|
|
134 |
FOREVER
|
|
135 |
{
|
|
136 |
User::After(2147483647); // max value, 35 minutes, 47 seconds
|
|
137 |
if(!gWriting)
|
|
138 |
RDebug::Print(_L("."));
|
|
139 |
}
|
|
140 |
}
|
|
141 |
|
|
142 |
/** Delete content of directory
|
|
143 |
|
|
144 |
@param aDir Directory to be emptied
|
|
145 |
*/
|
|
146 |
LOCAL_C TInt DeleteAll(TDes16& aDir)
|
|
147 |
{
|
|
148 |
TBuf16<100> dir;
|
|
149 |
CFileMan* fMan = CFileMan::NewL(TheFs);
|
|
150 |
TInt r = 0;
|
|
151 |
|
|
152 |
dir = aDir;
|
|
153 |
dir.Append(_L("F*.*"));
|
|
154 |
r = fMan->Delete(dir);
|
|
155 |
|
|
156 |
delete fMan;
|
|
157 |
return r;
|
|
158 |
}
|
|
159 |
|
|
160 |
|
|
161 |
/** Creates a file of aSize KBytes
|
|
162 |
|
|
163 |
@param aFile File name
|
|
164 |
@param aSize Size of the file to be created
|
|
165 |
*/
|
|
166 |
LOCAL_C void CreateFile(TDes16& aFile, TInt aSize)
|
|
167 |
{
|
|
168 |
TInt r = 0;
|
|
169 |
RFile file;
|
|
170 |
|
|
171 |
|
|
172 |
r = file.Replace(TheFs, aFile, EFileShareAny|EFileWrite);
|
|
173 |
FailIfError(r);
|
|
174 |
|
|
175 |
TInt j = 0;
|
|
176 |
while(j <= aSize)
|
|
177 |
{
|
|
178 |
r = file.Write(gBufWritePtr, KOneK);
|
|
179 |
FailIfError(r);
|
|
180 |
j += KOneK;
|
|
181 |
}
|
|
182 |
file.Close();
|
|
183 |
}
|
|
184 |
|
|
185 |
/** Kills the concurrent session
|
|
186 |
|
|
187 |
*/
|
|
188 |
LOCAL_C void DoTestKill()
|
|
189 |
{
|
|
190 |
TInt r = 0;
|
|
191 |
|
|
192 |
gSpeedy.Kill(KErrNone);
|
|
193 |
FailIfError(r);
|
|
194 |
gSpeedy.Close();
|
|
195 |
|
|
196 |
gSpeedyII.Kill(KErrNone);
|
|
197 |
FailIfError(r);
|
|
198 |
gSpeedyII.Close();
|
|
199 |
}
|
|
200 |
|
|
201 |
/** Read aSize KBs from aFile file in blocks of aBlockSize bytes
|
|
202 |
|
|
203 |
@param aFile Name of the file
|
|
204 |
@param aPos Position from where the read starts within the file
|
|
205 |
@param aBlockSize Block size for the I/O operation
|
|
206 |
@param aSize
|
|
207 |
*/
|
|
208 |
LOCAL_C TInt ReadFromFile(TDes16& aFile, TInt aPos, TInt aBlockSize, TInt aSize)
|
|
209 |
{
|
|
210 |
TInt r = 0;
|
|
211 |
TTime startTime;
|
|
212 |
TTime endTime;
|
|
213 |
RFile file;
|
|
214 |
TInt j = 0;
|
|
215 |
TInt size = aSize * KOneK;
|
|
216 |
TTimeIntervalMicroSeconds timeTaken(0);
|
|
217 |
|
|
218 |
r = file.Open(TheFs,aFile,EFileShareAny|EFileRead);
|
|
219 |
FailIfError(r);
|
|
220 |
|
|
221 |
startTime.HomeTime();
|
|
222 |
r = file.Seek(ESeekStart, aPos);
|
|
223 |
FailIfError(r);
|
|
224 |
|
|
225 |
while(j <= size)
|
|
226 |
{
|
|
227 |
r = file.Read(gBufReadPtr, aBlockSize);
|
|
228 |
FailIfError(r);
|
|
229 |
j += aBlockSize;
|
|
230 |
}
|
|
231 |
endTime.HomeTime();
|
|
232 |
|
|
233 |
file.Close();
|
|
234 |
timeTaken = endTime.MicroSecondsFrom(startTime);
|
|
235 |
|
|
236 |
return I64LOW(timeTaken.Int64() / gTimeUnit);
|
|
237 |
}
|
|
238 |
|
|
239 |
/** Read aSize KBs from aFile file in blocks of aBlockSize bytes several times
|
|
240 |
|
|
241 |
@param aFile Name of the file
|
|
242 |
@param ayMax Maximum for the position
|
|
243 |
@param aBlockSize Block size for the I/O operation
|
|
244 |
@param aSize Size of the file in KB
|
|
245 |
*/
|
|
246 |
LOCAL_C TInt ReadFromFileSeveralTimes(TDes16& aFile, TInt ayMax, TInt aBlockSize, TInt aSize)
|
|
247 |
{
|
|
248 |
TInt r = 0;
|
|
249 |
TTime startTime;
|
|
250 |
TTime endTime;
|
|
251 |
RFile file;
|
|
252 |
TInt j = 0, i, pos;
|
|
253 |
TInt size = aSize * KOneK;
|
|
254 |
TTimeIntervalMicroSeconds timeTaken(0);
|
|
255 |
TInt64 time = 0;
|
|
256 |
|
|
257 |
|
|
258 |
r = file.Open(TheFs, aFile, EFileShareAny|EFileRead);
|
|
259 |
FailIfError(r);
|
|
260 |
|
|
261 |
i = 0;
|
|
262 |
while( i < KSeveralTimes )
|
|
263 |
{
|
|
264 |
pos = Rand(Pow(ayMax - 1));
|
|
265 |
startTime.HomeTime();
|
|
266 |
r = file.Seek(ESeekStart, pos);
|
|
267 |
FailIfError(r);
|
|
268 |
|
|
269 |
j = 0;
|
|
270 |
while(j <= size)
|
|
271 |
{
|
|
272 |
r = file.Read(gBufReadPtr, aBlockSize);
|
|
273 |
FailIfError(r);
|
|
274 |
j += aBlockSize;
|
|
275 |
}
|
|
276 |
endTime.HomeTime();
|
|
277 |
|
|
278 |
timeTaken = endTime.MicroSecondsFrom(startTime);
|
|
279 |
time += I64LOW(timeTaken.Int64());
|
|
280 |
i++;
|
|
281 |
}
|
|
282 |
|
|
283 |
file.Close();
|
|
284 |
|
|
285 |
return I64LOW((time / gTimeUnit) / KSeveralTimes); // Overflow not expected here, since the number is not big enough
|
|
286 |
}
|
|
287 |
|
|
288 |
|
|
289 |
/** Write aSize KBs to aFile file in blocks of aBlockSize bytes
|
|
290 |
|
|
291 |
@param aFile Name of the file
|
|
292 |
@param aPos Position from where the read starts within the file
|
|
293 |
@param aBlockSize Block size for the I/O operation
|
|
294 |
@param aSize Size of the file in KB
|
|
295 |
*/
|
|
296 |
LOCAL_C TInt WriteToFile(TDes16& aFile, TInt aPos, TInt aBlockSize, TInt aSize)
|
|
297 |
{
|
|
298 |
TInt r = 0;
|
|
299 |
TTime startTime;
|
|
300 |
TTime endTime;
|
|
301 |
RFile file;
|
|
302 |
TInt j = 0;
|
|
303 |
TInt size = aSize * KOneK;
|
|
304 |
TTimeIntervalMicroSeconds timeTaken(0);
|
|
305 |
|
|
306 |
r = file.Open(TheFs, aFile, EFileShareAny|EFileWrite);
|
|
307 |
FailIfError(r);
|
|
308 |
|
|
309 |
startTime.HomeTime();
|
|
310 |
r = file.Seek(ESeekStart, aPos);
|
|
311 |
FailIfError(r);
|
|
312 |
while(j <= size)
|
|
313 |
{
|
|
314 |
r = file.Write(gBufWritePtr, aBlockSize);
|
|
315 |
FailIfError(r);
|
|
316 |
j += aBlockSize;
|
|
317 |
}
|
|
318 |
endTime.HomeTime();
|
|
319 |
|
|
320 |
file.Close();
|
|
321 |
timeTaken = endTime.MicroSecondsFrom(startTime);
|
|
322 |
|
|
323 |
return I64LOW(timeTaken.Int64() / gTimeUnit);
|
|
324 |
}
|
|
325 |
|
|
326 |
/** Write aSize KBs to aFile file in blocks of aBlockSize bytes several times
|
|
327 |
|
|
328 |
@param aFile Name of the file
|
|
329 |
@param ayMax Maximum for the position
|
|
330 |
@param aBlockSize Block size for the I/O operation
|
|
331 |
@param aSize Size of the file in KB
|
|
332 |
*/
|
|
333 |
LOCAL_C TInt WriteToFileSeveralTimes(TDes16& aFile, TInt ayMax, TInt aBlockSize, TInt aSize)
|
|
334 |
{
|
|
335 |
TInt r = 0;
|
|
336 |
TTime startTime;
|
|
337 |
TTime endTime;
|
|
338 |
RFile file;
|
|
339 |
TInt i, j = 0, pos;
|
|
340 |
TInt size = aSize * KOneK;
|
|
341 |
TTimeIntervalMicroSeconds timeTaken(0);
|
|
342 |
TInt64 time = 0;
|
|
343 |
|
|
344 |
r = file.Open(TheFs, aFile, EFileShareAny|EFileWrite);
|
|
345 |
FailIfError(r);
|
|
346 |
|
|
347 |
i = 0;
|
|
348 |
while( i < KSeveralTimes )
|
|
349 |
{
|
|
350 |
pos = Rand(Pow(ayMax - 1));
|
|
351 |
startTime.HomeTime();
|
|
352 |
r = file.Seek(ESeekStart, pos);
|
|
353 |
FailIfError(r);
|
|
354 |
|
|
355 |
j = 0;
|
|
356 |
while(j <= size)
|
|
357 |
{
|
|
358 |
r = file.Write(gBufWritePtr, aBlockSize);
|
|
359 |
FailIfError(r);
|
|
360 |
j += aBlockSize;
|
|
361 |
}
|
|
362 |
endTime.HomeTime();
|
|
363 |
|
|
364 |
timeTaken = endTime.MicroSecondsFrom(startTime);
|
|
365 |
time += I64LOW(timeTaken.Int64());
|
|
366 |
i++;
|
|
367 |
}
|
|
368 |
|
|
369 |
file.Close();
|
|
370 |
|
|
371 |
return I64LOW((time / gTimeUnit) / KSeveralTimes); // Overflow not expected here, since the number is not big enough
|
|
372 |
}
|
|
373 |
|
|
374 |
/** Read small blocks in the gBaseFile
|
|
375 |
|
|
376 |
*/
|
|
377 |
LOCAL_C TInt ReadSmallBase(TAny* )
|
|
378 |
{
|
|
379 |
RTest test(_L("test 2"));
|
|
380 |
RFs fs;
|
|
381 |
RFile file;
|
|
382 |
TBuf8<1024> dummy(1024);
|
|
383 |
TInt blockSize = 0;
|
|
384 |
TInt randPos = 0;
|
|
385 |
TInt i = 0;
|
|
386 |
|
|
387 |
TInt r = fs.Connect();
|
|
388 |
|
|
389 |
fs.SetSessionPath(gSessionPath);
|
|
390 |
r = file.Open(fs, gBaseFile, EFileShareAny|EFileRead);
|
|
391 |
client.Signal();
|
|
392 |
|
|
393 |
FailIfError(r);
|
|
394 |
|
|
395 |
FOREVER
|
|
396 |
{
|
|
397 |
randPos = Rand(64) * KOneK ;
|
|
398 |
r = file.Seek(ESeekStart, randPos);
|
|
399 |
FailIfError(r);
|
|
400 |
blockSize = i;
|
|
401 |
|
|
402 |
r = file.Read(dummy, blockSize); // Sync operation
|
|
403 |
if(i >= 1023) i = 0;
|
|
404 |
else i++;
|
|
405 |
}
|
|
406 |
}
|
|
407 |
|
|
408 |
/** Read small blocks in gFileA
|
|
409 |
|
|
410 |
*/
|
|
411 |
LOCAL_C TInt ReadSmallA(TAny* )
|
|
412 |
{
|
|
413 |
RTest test(_L("test 2"));
|
|
414 |
RFs fs;
|
|
415 |
RFile file;
|
|
416 |
TInt blockSize = 0;
|
|
417 |
TInt randPos = 0;
|
|
418 |
TBuf8<1024> dummy(1024);
|
|
419 |
TInt i = 0;
|
|
420 |
|
|
421 |
TInt r = fs.Connect();
|
|
422 |
|
|
423 |
fs.SetSessionPath(gSessionPath);
|
|
424 |
|
|
425 |
r = file.Open(fs,gFileA,EFileShareAny|EFileRead);
|
|
426 |
|
|
427 |
client.Signal();
|
|
428 |
FailIfError(r);
|
|
429 |
|
|
430 |
FOREVER
|
|
431 |
{
|
|
432 |
randPos = Rand(64) * KOneK ;
|
|
433 |
r = file.Seek(ESeekStart, randPos);
|
|
434 |
FailIfError(r);
|
|
435 |
|
|
436 |
blockSize = i;
|
|
437 |
|
|
438 |
r = file.Read(dummy, blockSize); // Sync operation
|
|
439 |
FailIfError(r);
|
|
440 |
if(i >= 1023) i = 0;
|
|
441 |
else i++;
|
|
442 |
}
|
|
443 |
}
|
|
444 |
|
|
445 |
/** Read small blocks in gFileB
|
|
446 |
|
|
447 |
*/
|
|
448 |
LOCAL_C TInt ReadSmallB(TAny* )
|
|
449 |
{
|
|
450 |
RTest test(_L("test 2"));
|
|
451 |
RFs fs;
|
|
452 |
RFile file;
|
|
453 |
TBuf8<1024> dummy(1024);
|
|
454 |
TInt blockSize = 0;
|
|
455 |
TInt randPos = 0;
|
|
456 |
TInt i = 0;
|
|
457 |
|
|
458 |
TInt r = fs.Connect();
|
|
459 |
|
|
460 |
fs.SetSessionPath(gSessionPath);
|
|
461 |
r = file.Open(fs, gFileB, EFileShareAny|EFileRead);
|
|
462 |
|
|
463 |
client.Signal();
|
|
464 |
FailIfError(r);
|
|
465 |
|
|
466 |
FOREVER
|
|
467 |
{
|
|
468 |
randPos = Rand(64) * KOneK ;
|
|
469 |
r = file.Seek(ESeekStart, randPos);
|
|
470 |
FailIfError(r);
|
|
471 |
blockSize = i;
|
|
472 |
|
|
473 |
r = file.Read(dummy, blockSize); // Sync operation
|
|
474 |
FailIfError(r);
|
|
475 |
if(i >= 1023) i = 0;
|
|
476 |
else i++;
|
|
477 |
}
|
|
478 |
}
|
|
479 |
|
|
480 |
|
|
481 |
/** Read large blocks in gBaseFile
|
|
482 |
|
|
483 |
*/
|
|
484 |
LOCAL_C TInt ReadLargeBase(TAny* )
|
|
485 |
{
|
|
486 |
RTest test(_L("test 2"));
|
|
487 |
RFs fs;
|
|
488 |
RFile file;
|
|
489 |
TInt pos = 0;
|
|
490 |
TInt blockSize = 128 * KOneK;
|
|
491 |
|
|
492 |
TInt r = fs.Connect();
|
|
493 |
|
|
494 |
fs.SetSessionPath(gSessionPath);
|
|
495 |
r = file.Open(fs,gBaseFile,EFileShareAny|EFileRead);
|
|
496 |
|
|
497 |
client.Signal();
|
|
498 |
FailIfError(r);
|
|
499 |
|
|
500 |
FOREVER
|
|
501 |
{
|
|
502 |
r = file.Seek(ESeekStart, pos);
|
|
503 |
FailIfError(r);
|
|
504 |
|
|
505 |
r = file.Read(gBufReadBPtr, blockSize); // Sync operation
|
|
506 |
FailIfError(r);
|
|
507 |
}
|
|
508 |
}
|
|
509 |
|
|
510 |
/** Read large blocks in gFileA
|
|
511 |
|
|
512 |
*/
|
|
513 |
LOCAL_C TInt ReadLargeA(TAny* )
|
|
514 |
{
|
|
515 |
RTest test(_L("test 2"));
|
|
516 |
RFs fs;
|
|
517 |
RFile file;
|
|
518 |
TInt blockSize = 128 * KOneK;
|
|
519 |
TInt pos = 0;
|
|
520 |
|
|
521 |
TInt r = fs.Connect();
|
|
522 |
|
|
523 |
fs.SetSessionPath(gSessionPath);
|
|
524 |
|
|
525 |
r = file.Open(fs,gFileA,EFileShareAny|EFileRead);
|
|
526 |
|
|
527 |
client.Signal();
|
|
528 |
FailIfError(r);
|
|
529 |
|
|
530 |
FOREVER
|
|
531 |
{
|
|
532 |
r = file.Seek(ESeekStart, pos);
|
|
533 |
FailIfError(r);
|
|
534 |
|
|
535 |
r = file.Read(gBufReadBPtr, blockSize); // Sync operation
|
|
536 |
FailIfError(r);
|
|
537 |
}
|
|
538 |
}
|
|
539 |
|
|
540 |
/** Read large blocks in gFileB
|
|
541 |
|
|
542 |
*/
|
|
543 |
LOCAL_C TInt ReadLargeB(TAny* )
|
|
544 |
{
|
|
545 |
RTest test(_L("test 2"));
|
|
546 |
RFs fs;
|
|
547 |
RFile file;
|
|
548 |
TInt blockSize = 128 * KOneK;
|
|
549 |
TInt pos = 0;
|
|
550 |
|
|
551 |
TInt r=fs.Connect();
|
|
552 |
FailIfError(r);
|
|
553 |
|
|
554 |
fs.SetSessionPath(gSessionPath);
|
|
555 |
|
|
556 |
r = file.Open(fs,gFileB,EFileShareAny|EFileRead);
|
|
557 |
|
|
558 |
client.Signal();
|
|
559 |
FailIfError(r);
|
|
560 |
|
|
561 |
FOREVER
|
|
562 |
{
|
|
563 |
r = file.Seek(ESeekStart, pos);
|
|
564 |
FailIfError(r);
|
|
565 |
|
|
566 |
r = file.Read(gBufReadBPtr, blockSize); // Sync operation
|
|
567 |
FailIfError(r);
|
|
568 |
}
|
|
569 |
}
|
|
570 |
|
|
571 |
/** Small reads from a file
|
|
572 |
|
|
573 |
@param xMax Maximum position on the x axe
|
|
574 |
@param yMax Maximum position on the y axe
|
|
575 |
@param aCase Type of test. Possible values:
|
|
576 |
- ENoThreads : isolated
|
|
577 |
- ETwoThreadsSame : with two threads accessing same file
|
|
578 |
- ETwoThreadsDif : with two threads accessing dif. files
|
|
579 |
*/
|
|
580 |
LOCAL_C void smallReads(TInt xMax, TInt yMax, TTestState aCase)
|
|
581 |
{
|
|
582 |
TInt i = 0;
|
|
583 |
TInt j = 0;
|
|
584 |
TInt r = 0;
|
|
585 |
TInt timeRes = 0;
|
|
586 |
|
|
587 |
CreateFile(gBaseFile, Pow(yMax-1));
|
|
588 |
|
|
589 |
if(aCase == ETwoThreadsSame)
|
|
590 |
{ // Start two different threads accessing the same file
|
|
591 |
TBuf<20> buf = _L("Speedy");
|
|
592 |
buf.AppendNum(ThreadCount++);
|
|
593 |
r = gSpeedy.Create(buf, ReadSmallBase, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
594 |
FailIfError(r);
|
|
595 |
|
|
596 |
buf = _L("Speedy");
|
|
597 |
buf.AppendNum(ThreadCount++);
|
|
598 |
|
|
599 |
r = gSpeedyII.Create(buf, ReadSmallBase, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
600 |
FailIfError(r);
|
|
601 |
|
|
602 |
gSpeedy.Resume();
|
|
603 |
gSpeedyII.Resume();
|
|
604 |
|
|
605 |
client.Wait();
|
|
606 |
client.Wait();
|
|
607 |
}
|
|
608 |
|
|
609 |
if(aCase == ETwoThreadsDif)
|
|
610 |
{ // Start two different threads accessing different files
|
|
611 |
CreateFile(gFileA, Pow(yMax-1));
|
|
612 |
CreateFile(gFileB, Pow(yMax-1));
|
|
613 |
|
|
614 |
TBuf<20> buf = _L("Speedy");
|
|
615 |
buf.AppendNum(ThreadCount++);
|
|
616 |
r = gSpeedy.Create(buf, ReadSmallA, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
617 |
FailIfError(r);
|
|
618 |
|
|
619 |
buf = _L("Speedy");
|
|
620 |
buf.AppendNum(ThreadCount++);
|
|
621 |
|
|
622 |
r = gSpeedyII.Create(buf, ReadSmallB, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
623 |
FailIfError(r);
|
|
624 |
|
|
625 |
gSpeedy.Resume();
|
|
626 |
gSpeedyII.Resume();
|
|
627 |
|
|
628 |
client.Wait();
|
|
629 |
client.Wait();
|
|
630 |
}
|
|
631 |
|
|
632 |
while(i < xMax)
|
|
633 |
{ // Actual accesses and timing to the main file
|
|
634 |
j = 0;
|
|
635 |
PrintResult(i + 1, j + 1, Pow(i));
|
|
636 |
while(j < yMax)
|
|
637 |
{
|
|
638 |
if(Pow(i) < KSmallThreshold)
|
|
639 |
{
|
|
640 |
timeRes = ReadFromFile(gBaseFile, Rand(Pow(yMax - 1)), Pow(i), Pow(j));
|
|
641 |
}
|
|
642 |
else
|
|
643 |
{ // Too small for only one time measure
|
|
644 |
timeRes = ReadFromFileSeveralTimes(gBaseFile, yMax, Pow(i), Pow(j));
|
|
645 |
}
|
|
646 |
|
|
647 |
gWriting = ETrue;
|
|
648 |
User::After(1000000);
|
|
649 |
|
|
650 |
PrintResultTime(i + 1, j + 2, timeRes);
|
|
651 |
|
|
652 |
gWriting = EFalse;
|
|
653 |
|
|
654 |
j++;
|
|
655 |
}
|
|
656 |
i++;
|
|
657 |
}
|
|
658 |
|
|
659 |
|
|
660 |
if((aCase == ETwoThreadsSame) || (aCase == ETwoThreadsDif))
|
|
661 |
{ // Finish the threads
|
|
662 |
DoTestKill();
|
|
663 |
}
|
|
664 |
}
|
|
665 |
|
|
666 |
/** Large reads from a file
|
|
667 |
|
|
668 |
@param xMax Maximum position on the x axe
|
|
669 |
@param yMax Maximum position on the y axe
|
|
670 |
@param aCase Type of test. Possible values:
|
|
671 |
- ENoThreads : isolated
|
|
672 |
- ETwoThreadsSame : with two threads accessing same file
|
|
673 |
- ETwoThreadsDif : with two threads accessing dif. files
|
|
674 |
- ETwoThreadsDifDif : with two threads accessing dif. files, different block sizes (big/small)
|
|
675 |
*/
|
|
676 |
LOCAL_C void largeReads(TInt xMax, TInt yMax, TTestState aCase)
|
|
677 |
{
|
|
678 |
TInt i = 0;
|
|
679 |
TInt j = 0;
|
|
680 |
TInt r = 0;
|
|
681 |
TInt timeRes = 0;
|
|
682 |
|
|
683 |
CreateFile(gBaseFile, 10 * KOneK * KOneK); // 10 Mb
|
|
684 |
|
|
685 |
if(aCase == ETwoThreadsSame)
|
|
686 |
{ // Start two different threads accessing the same file
|
|
687 |
|
|
688 |
TRAPD(res, gBufB = HBufC8::NewL(256 * KOneK));
|
|
689 |
test(res == KErrNone && gBufB != NULL);
|
|
690 |
gBufReadBPtr.Set(gBufSec->Des());
|
|
691 |
|
|
692 |
TBuf<20> buf = _L("Speedy");
|
|
693 |
buf.AppendNum(ThreadCount++);
|
|
694 |
r = gSpeedy.Create(buf, ReadLargeBase, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
695 |
FailIfError(r);
|
|
696 |
|
|
697 |
buf = _L("Speedy");
|
|
698 |
buf.AppendNum(ThreadCount++);
|
|
699 |
|
|
700 |
r = gSpeedyII.Create(buf, ReadLargeBase, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
701 |
FailIfError(r);
|
|
702 |
|
|
703 |
gSpeedy.Resume();
|
|
704 |
gSpeedyII.Resume();
|
|
705 |
|
|
706 |
client.Wait();
|
|
707 |
client.Wait();
|
|
708 |
}
|
|
709 |
|
|
710 |
if(aCase == ETwoThreadsDif)
|
|
711 |
{ // Start two different threads accessing different files
|
|
712 |
|
|
713 |
CreateFile(gFileA, KOneK * KOneK);
|
|
714 |
CreateFile(gFileB, KOneK * KOneK);
|
|
715 |
|
|
716 |
TRAPD(res, gBufB = HBufC8::NewL(256 * KOneK));
|
|
717 |
test(res == KErrNone && gBufB != NULL);
|
|
718 |
gBufReadBPtr.Set(gBufSec->Des());
|
|
719 |
|
|
720 |
TBuf<20> buf = _L("Speedy");
|
|
721 |
buf.AppendNum(ThreadCount++);
|
|
722 |
r = gSpeedy.Create(buf, ReadLargeA, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
723 |
FailIfError(r);
|
|
724 |
|
|
725 |
buf = _L("Speedy");
|
|
726 |
buf.AppendNum(ThreadCount++);
|
|
727 |
|
|
728 |
r = gSpeedyII.Create(buf, ReadLargeB, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
729 |
FailIfError(r);
|
|
730 |
|
|
731 |
gSpeedy.Resume();
|
|
732 |
gSpeedyII.Resume();
|
|
733 |
|
|
734 |
client.Wait();
|
|
735 |
client.Wait();
|
|
736 |
}
|
|
737 |
|
|
738 |
if(aCase == ETwoThreadsDifDif)
|
|
739 |
{ // Start two different threads accessing different files
|
|
740 |
|
|
741 |
CreateFile(gFileA, KOneK * KOneK);
|
|
742 |
CreateFile(gFileB, KOneK * KOneK);
|
|
743 |
|
|
744 |
TRAPD(res,gBufB = HBufC8::NewL(256 * KOneK));
|
|
745 |
test(res == KErrNone && gBufB != NULL);
|
|
746 |
gBufReadBPtr.Set(gBufSec->Des());
|
|
747 |
|
|
748 |
TBuf<20> buf=_L("Speedy");
|
|
749 |
buf.AppendNum(ThreadCount++);
|
|
750 |
r = gSpeedy.Create(buf, ReadLargeA, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
751 |
FailIfError(r);
|
|
752 |
|
|
753 |
buf = _L("Speedy");
|
|
754 |
buf.AppendNum(ThreadCount++);
|
|
755 |
|
|
756 |
r = gSpeedyII.Create(buf, ReadSmallB, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
757 |
FailIfError(r);
|
|
758 |
|
|
759 |
gSpeedy.Resume();
|
|
760 |
gSpeedyII.Resume();
|
|
761 |
|
|
762 |
client.Wait();
|
|
763 |
client.Wait();
|
|
764 |
}
|
|
765 |
|
|
766 |
i = 11;
|
|
767 |
while(i < xMax )
|
|
768 |
{ // Actual accesses and timing to the main file
|
|
769 |
j = 0;
|
|
770 |
PrintResult(i - 10, j + 1, Pow(i));
|
|
771 |
while(j < yMax)
|
|
772 |
{
|
|
773 |
TInt size=0;
|
|
774 |
if(j == 0) size = 100 ; // 100 Kb
|
|
775 |
if(j == 1) size = KOneK ; // 1 Mb
|
|
776 |
if(j == 2) size = 10 * KOneK ; // 10 Mb
|
|
777 |
|
|
778 |
timeRes = ReadFromFile(gBaseFile, 0, Pow(i), size);
|
|
779 |
|
|
780 |
gWriting = ETrue;
|
|
781 |
User::After(1000000);
|
|
782 |
|
|
783 |
PrintResultTime(i - 10, j + 2, timeRes);
|
|
784 |
|
|
785 |
gWriting = EFalse;
|
|
786 |
|
|
787 |
j++;
|
|
788 |
}
|
|
789 |
i++;
|
|
790 |
}
|
|
791 |
|
|
792 |
if((aCase == ETwoThreadsSame) || (aCase == ETwoThreadsDif) || (aCase == ETwoThreadsDifDif))
|
|
793 |
{ // Finish the threads
|
|
794 |
DoTestKill();
|
|
795 |
delete gBufB;
|
|
796 |
}
|
|
797 |
|
|
798 |
}
|
|
799 |
|
|
800 |
/** Large writes to a file
|
|
801 |
|
|
802 |
@param xMax Maximum position on the x axe
|
|
803 |
@param yMax Maximum position on the y axe
|
|
804 |
@param aCase Type of test. Possible values:
|
|
805 |
- ENoThreads : isolated
|
|
806 |
- ETwoThreadsSame : with two threads accessing same file
|
|
807 |
- ETwoThreadsDif : with two threads accessing dif. files
|
|
808 |
*/
|
|
809 |
LOCAL_C void largeWrites(TInt xMax, TInt yMax, TTestState aCase)
|
|
810 |
{
|
|
811 |
TInt i = 0;
|
|
812 |
TInt j = 0;
|
|
813 |
TInt r = 0;
|
|
814 |
TInt timeRes = 0;
|
|
815 |
|
|
816 |
CreateFile(gBaseFile, 10 * KOneK * KOneK); // 10 Mb
|
|
817 |
|
|
818 |
if(aCase == ETwoThreadsSame)
|
|
819 |
{ // Start two different threads accessing the same file
|
|
820 |
|
|
821 |
TRAPD(res, gBufB = HBufC8::NewL(256 * KOneK));
|
|
822 |
test(res == KErrNone && gBufB != NULL);
|
|
823 |
gBufReadBPtr.Set(gBufSec->Des());
|
|
824 |
|
|
825 |
TBuf<20> buf = _L("Speedy");
|
|
826 |
buf.AppendNum(ThreadCount++);
|
|
827 |
r = gSpeedy.Create(buf, ReadLargeBase, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
828 |
FailIfError(r);
|
|
829 |
|
|
830 |
buf = _L("Speedy");
|
|
831 |
buf.AppendNum(ThreadCount++);
|
|
832 |
|
|
833 |
r = gSpeedyII.Create(buf, ReadLargeBase, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
834 |
FailIfError(r);
|
|
835 |
|
|
836 |
gSpeedy.Resume();
|
|
837 |
gSpeedyII.Resume();
|
|
838 |
|
|
839 |
client.Wait();
|
|
840 |
client.Wait();
|
|
841 |
}
|
|
842 |
|
|
843 |
if(aCase == ETwoThreadsDif)
|
|
844 |
{ // Start two different threads accessing different files
|
|
845 |
|
|
846 |
CreateFile(gFileA, KOneK * KOneK);
|
|
847 |
CreateFile(gFileB, KOneK * KOneK);
|
|
848 |
|
|
849 |
TRAPD(res, gBufB = HBufC8::NewL(256 * KOneK));
|
|
850 |
test(res == KErrNone && gBufB != NULL);
|
|
851 |
gBufReadBPtr.Set(gBufSec->Des());
|
|
852 |
|
|
853 |
TBuf<20> buf = _L("Speedy");
|
|
854 |
buf.AppendNum(ThreadCount++);
|
|
855 |
r = gSpeedy.Create(buf, ReadLargeA, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
856 |
FailIfError(r);
|
|
857 |
|
|
858 |
buf = _L("Speedy");
|
|
859 |
buf.AppendNum(ThreadCount++);
|
|
860 |
|
|
861 |
r = gSpeedyII.Create(buf, ReadLargeB, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
862 |
FailIfError(r);
|
|
863 |
|
|
864 |
gSpeedy.Resume();
|
|
865 |
gSpeedyII.Resume();
|
|
866 |
|
|
867 |
client.Wait();
|
|
868 |
client.Wait();
|
|
869 |
}
|
|
870 |
|
|
871 |
i = 11;
|
|
872 |
while(i < xMax )
|
|
873 |
{ // Actual accesses and timing to the main file
|
|
874 |
j = 0;
|
|
875 |
PrintResult(i - 10 , j + 1, Pow(i));
|
|
876 |
while(j < yMax)
|
|
877 |
{
|
|
878 |
TInt size=0;
|
|
879 |
if(j == 0) size = 100 ; // 100 Kb
|
|
880 |
if(j == 1) size = KOneK ; // 1 Mb
|
|
881 |
if(j == 2) size = 10 * KOneK ; // 10 Mb
|
|
882 |
timeRes = WriteToFile(gBaseFile, 0, Pow(i), size);
|
|
883 |
|
|
884 |
gWriting = ETrue;
|
|
885 |
User::After(1000000);
|
|
886 |
|
|
887 |
PrintResultTime(i - 10, j + 2, timeRes);
|
|
888 |
|
|
889 |
gWriting = EFalse;
|
|
890 |
j++;
|
|
891 |
}
|
|
892 |
i++;
|
|
893 |
}
|
|
894 |
|
|
895 |
if((aCase == ETwoThreadsSame) || (aCase == ETwoThreadsDif) || (aCase == ETwoThreadsDifDif))
|
|
896 |
{ // Finish the threads
|
|
897 |
DoTestKill();
|
|
898 |
delete gBufB;
|
|
899 |
}
|
|
900 |
|
|
901 |
}
|
|
902 |
|
|
903 |
/** Small writes to a file
|
|
904 |
|
|
905 |
@param xMax Maximum position on the x axe
|
|
906 |
@param yMax Maximum position on the y axe
|
|
907 |
@param aCase Type of test. Possible values:
|
|
908 |
- ENoThreads : isolated
|
|
909 |
- ETwoThreadsSame : with two threads accessing same file
|
|
910 |
- ETwoThreadsDif : with two threads accessing dif. files
|
|
911 |
*/
|
|
912 |
LOCAL_C void smallWrites(TInt xMax, TInt yMax, TTestState aCase)
|
|
913 |
{
|
|
914 |
TInt i = 0;
|
|
915 |
TInt j = 0;
|
|
916 |
TInt r = 0;
|
|
917 |
TInt timeRes = 0;
|
|
918 |
|
|
919 |
CreateFile(gBaseFile, Pow(yMax-1));
|
|
920 |
|
|
921 |
if(aCase == ETwoThreadsSame)
|
|
922 |
{ // Start two different threads accessing the same file
|
|
923 |
TBuf<20> buf = _L("Speedy");
|
|
924 |
buf.AppendNum(ThreadCount++);
|
|
925 |
r = gSpeedy.Create(buf, ReadSmallBase, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
926 |
FailIfError(r);
|
|
927 |
|
|
928 |
buf = _L("Speedy");
|
|
929 |
buf.AppendNum(ThreadCount++);
|
|
930 |
|
|
931 |
r = gSpeedyII.Create(buf, ReadSmallBase, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
932 |
FailIfError(r);
|
|
933 |
|
|
934 |
gSpeedy.Resume();
|
|
935 |
gSpeedyII.Resume();
|
|
936 |
|
|
937 |
client.Wait();
|
|
938 |
client.Wait();
|
|
939 |
}
|
|
940 |
|
|
941 |
if(aCase == ETwoThreadsDif)
|
|
942 |
{ // Start two different threads accessing different files
|
|
943 |
CreateFile(gFileA, Pow(yMax-1));
|
|
944 |
CreateFile(gFileB, Pow(yMax-1));
|
|
945 |
|
|
946 |
TBuf<20> buf = _L("Speedy");
|
|
947 |
buf.AppendNum(ThreadCount++);
|
|
948 |
r = gSpeedy.Create(buf, ReadSmallA, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
949 |
FailIfError(r);
|
|
950 |
|
|
951 |
buf = _L("Speedy");
|
|
952 |
buf.AppendNum(ThreadCount++);
|
|
953 |
|
|
954 |
r = gSpeedyII.Create(buf, ReadSmallB, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
955 |
FailIfError(r);
|
|
956 |
|
|
957 |
gSpeedy.Resume();
|
|
958 |
gSpeedyII.Resume();
|
|
959 |
|
|
960 |
client.Wait();
|
|
961 |
client.Wait();
|
|
962 |
}
|
|
963 |
|
|
964 |
while(i < xMax)
|
|
965 |
{
|
|
966 |
j = 0;
|
|
967 |
PrintResult(i + 1, j + 1, Pow(i));
|
|
968 |
while(j < yMax)
|
|
969 |
{
|
|
970 |
if(Pow(i) < KSmallThreshold)
|
|
971 |
{
|
|
972 |
timeRes = WriteToFile(gBaseFile, Rand(Pow(yMax-1)), Pow(i), Pow(j));
|
|
973 |
}
|
|
974 |
else
|
|
975 |
{
|
|
976 |
timeRes = WriteToFileSeveralTimes(gBaseFile, yMax, Pow(i), Pow(j));
|
|
977 |
}
|
|
978 |
|
|
979 |
gWriting = ETrue;
|
|
980 |
User::After(1000000);
|
|
981 |
|
|
982 |
PrintResultTime(i + 1, j + 2, timeRes);
|
|
983 |
|
|
984 |
gWriting = EFalse;
|
|
985 |
|
|
986 |
j++;
|
|
987 |
}
|
|
988 |
i++;
|
|
989 |
}
|
|
990 |
|
|
991 |
if((aCase == ETwoThreadsSame) || (aCase == ETwoThreadsDif))
|
|
992 |
{ // Finish the threads
|
|
993 |
DoTestKill();
|
|
994 |
}
|
|
995 |
|
|
996 |
}
|
|
997 |
|
|
998 |
/** This test benchmarks small random r/w (e.g. database access)
|
|
999 |
|
|
1000 |
@param aSelector Selection array for manual tests
|
|
1001 |
*/
|
|
1002 |
LOCAL_C TInt TestSmall(TAny* aSelector)
|
|
1003 |
{
|
|
1004 |
|
|
1005 |
Validate(aSelector);
|
|
1006 |
|
|
1007 |
// Each test case of the suite has an identifyer for parsing purposes of the results
|
|
1008 |
gTestHarness = 7;
|
|
1009 |
gTestCase = 1;
|
|
1010 |
gTimeUnit = 1;
|
|
1011 |
|
|
1012 |
PrintHeaders(4, _L("t_fcachebm. Small Random r/w"));
|
|
1013 |
|
|
1014 |
// Small reads
|
|
1015 |
test.Printf(_L("#~TS_Title_%d,%d: Small reads, no threads \n"), gTestHarness, gTestCase);
|
|
1016 |
|
|
1017 |
smallReads(KSmallRow, KSmallCol, ENoThreads);
|
|
1018 |
|
|
1019 |
gTestCase++;
|
|
1020 |
test.Printf(_L("#~TS_Title_%d,%d: Small reads, threads accessing same file \n"),
|
|
1021 |
gTestHarness, gTestCase);
|
|
1022 |
|
|
1023 |
smallReads(KSmallRow, KSmallCol, ETwoThreadsSame);
|
|
1024 |
|
|
1025 |
gTestCase++;
|
|
1026 |
test.Printf(_L("#~TS_Title_%d,%d: Small reads, threads accessing dif files \n"),
|
|
1027 |
gTestHarness, gTestCase);
|
|
1028 |
|
|
1029 |
smallReads(KSmallRow, KSmallCol, ETwoThreadsDif);
|
|
1030 |
|
|
1031 |
gTestCase++;
|
|
1032 |
DeleteAll(gSessionPath);
|
|
1033 |
|
|
1034 |
// Small writes test case
|
|
1035 |
|
|
1036 |
test.Printf(_L("#~TS_Title_%d,%d: Test small writes\n"), gTestHarness, gTestCase);
|
|
1037 |
|
|
1038 |
smallWrites(KSmallRow, KSmallCol, ENoThreads);
|
|
1039 |
|
|
1040 |
gTestCase++;
|
|
1041 |
test.Printf(_L("#~TS_Title_%d,%d: Small writes, threads accessing same file \n"),
|
|
1042 |
gTestHarness, gTestCase);
|
|
1043 |
smallWrites(KSmallRow, KSmallCol, ETwoThreadsSame);
|
|
1044 |
|
|
1045 |
gTestCase++;
|
|
1046 |
test.Printf(_L("#~TS_Title_%d,%d: Small writes, threads accessing dif files \n"),
|
|
1047 |
gTestHarness, gTestCase);
|
|
1048 |
smallWrites(KSmallRow, KSmallCol, ETwoThreadsDif);
|
|
1049 |
|
|
1050 |
gTestCase++;
|
|
1051 |
DeleteAll(gSessionPath);
|
|
1052 |
test.Printf(_L("#~TestEnd_%d\n"), gTestHarness);
|
|
1053 |
|
|
1054 |
return(KErrNone);
|
|
1055 |
}
|
|
1056 |
|
|
1057 |
/** This test benchmarks large sequential r/w (e.g. MM)
|
|
1058 |
|
|
1059 |
@param aSelector Selection array for manual tests
|
|
1060 |
*/
|
|
1061 |
LOCAL_C TInt TestLarge(TAny* aSelector)
|
|
1062 |
{
|
|
1063 |
|
|
1064 |
Validate(aSelector);
|
|
1065 |
|
|
1066 |
// Each test case of the suite has an identifyer for parsing purposes of the results
|
|
1067 |
gTestHarness = 8;
|
|
1068 |
gTestCase = 1;
|
|
1069 |
gTimeUnit = 1000;
|
|
1070 |
|
|
1071 |
PrintHeaders(3, _L("t_fcachebm. Large sequential r/w"));
|
|
1072 |
|
|
1073 |
// Large reads
|
|
1074 |
test.Printf(_L("#~TS_Title_%d,%d: Large sequential reads\n"), gTestHarness, gTestCase);
|
|
1075 |
|
|
1076 |
largeReads(KLargeRow, KLargeCol, ENoThreads);
|
|
1077 |
|
|
1078 |
gTestCase++;
|
|
1079 |
test.Printf(_L("#~TS_Title_%d,%d: Large sequential reads, threads accessing same file\n"),
|
|
1080 |
gTestHarness, gTestCase);
|
|
1081 |
largeReads(KLargeRow, KLargeCol, ETwoThreadsSame);
|
|
1082 |
|
|
1083 |
gTestCase++;
|
|
1084 |
test.Printf(_L("#~TS_Title_%d,%d: Large sequential reads, threads accessing dif files\n"),
|
|
1085 |
gTestHarness, gTestCase);
|
|
1086 |
largeReads(KLargeRow, KLargeCol, ETwoThreadsDif);
|
|
1087 |
|
|
1088 |
gTestCase++;
|
|
1089 |
test.Printf(_L("#~TS_Title_%d,%d: Large sequential reads, threads accessing dif files some big some small blocks\n"),
|
|
1090 |
gTestHarness, gTestCase);
|
|
1091 |
largeReads(KLargeRow, KLargeCol, ETwoThreadsDifDif);
|
|
1092 |
|
|
1093 |
gTestCase++;
|
|
1094 |
DeleteAll(gSessionPath);
|
|
1095 |
|
|
1096 |
// Large writings
|
|
1097 |
test.Printf(_L("#~TS_Title_%d,%d: Large sequential writes\n"), gTestHarness, gTestCase);
|
|
1098 |
|
|
1099 |
largeWrites(KLargeRow, KLargeCol, ENoThreads);
|
|
1100 |
|
|
1101 |
gTestCase++;
|
|
1102 |
test.Printf(_L("#~TS_Title_%d,%d: Large sequential writes, threads accessing same file\n"),
|
|
1103 |
gTestHarness, gTestCase);
|
|
1104 |
largeWrites(KLargeRow, KLargeCol, ETwoThreadsSame);
|
|
1105 |
|
|
1106 |
gTestCase++;
|
|
1107 |
test.Printf(_L("#~TS_Title_%d,%d: Large sequential writes, threads accessing dif files\n"),
|
|
1108 |
gTestHarness, gTestCase);
|
|
1109 |
largeWrites(KLargeRow, KLargeCol, ETwoThreadsDif);
|
|
1110 |
|
|
1111 |
gTestCase++;
|
|
1112 |
DeleteAll(gSessionPath);
|
|
1113 |
test.Printf(_L("#~TestEnd_%d\n"), gTestHarness);
|
|
1114 |
|
|
1115 |
return(KErrNone);
|
|
1116 |
}
|
|
1117 |
|
|
1118 |
/** Writes aSize bytes of data in aBlockSize during aTime seconds
|
|
1119 |
if the aSize bps is not met, it fails
|
|
1120 |
|
|
1121 |
@param f File to write to
|
|
1122 |
@param aSize Size in bytes of data to be written
|
|
1123 |
@param aBlockSize Block size to be used
|
|
1124 |
@param aTime Time during which the write has to happen in seconds
|
|
1125 |
*/
|
|
1126 |
LOCAL_C TBool writeStr( RFile f, TInt aSize, TInt aBlockSize, TInt aTime)
|
|
1127 |
{
|
|
1128 |
TInt r = 0, j = 0;
|
|
1129 |
TTime startTime, endTime;
|
|
1130 |
TTimeIntervalMicroSeconds timeTaken(0);
|
|
1131 |
TTimeIntervalMicroSeconds32 timeLeft(0);
|
|
1132 |
TBool onTarget = ETrue;
|
|
1133 |
|
|
1134 |
TInt time;
|
|
1135 |
|
|
1136 |
TInt i = 0;
|
|
1137 |
while((i < aTime) && onTarget)
|
|
1138 |
{
|
|
1139 |
// If measuring the CPU time
|
|
1140 |
|
|
1141 |
startTime.HomeTime();
|
|
1142 |
j = 0;
|
|
1143 |
while(j < aSize)
|
|
1144 |
{
|
|
1145 |
r = f.Write(gBufWritePtr, aBlockSize);
|
|
1146 |
FailIfError(r);
|
|
1147 |
j += aBlockSize;
|
|
1148 |
}
|
|
1149 |
endTime.HomeTime();
|
|
1150 |
|
|
1151 |
timeTaken = endTime.MicroSecondsFrom(startTime);
|
|
1152 |
time = I64LOW(timeTaken.Int64());
|
|
1153 |
if(time > KOneSec)
|
|
1154 |
{
|
|
1155 |
onTarget = EFalse;
|
|
1156 |
}
|
|
1157 |
|
|
1158 |
timeLeft = KOneSec - time;
|
|
1159 |
if(timeLeft.Int() >= 0)
|
|
1160 |
{
|
|
1161 |
User::After(timeLeft);
|
|
1162 |
}
|
|
1163 |
i++;
|
|
1164 |
}
|
|
1165 |
|
|
1166 |
return onTarget;
|
|
1167 |
}
|
|
1168 |
|
|
1169 |
/** Reads streaming
|
|
1170 |
|
|
1171 |
*/
|
|
1172 |
LOCAL_C TInt ReadStream(TAny*)
|
|
1173 |
{
|
|
1174 |
RTest test(_L("test 2"));
|
|
1175 |
RFs fs;
|
|
1176 |
RFile file;
|
|
1177 |
TInt j = 0;
|
|
1178 |
TTime startTime, endTime;
|
|
1179 |
TTimeIntervalMicroSeconds timeTaken(0);
|
|
1180 |
TTimeIntervalMicroSeconds32 timeLeft(0);
|
|
1181 |
TInt time;
|
|
1182 |
TInt size , currentPos = 0;
|
|
1183 |
|
|
1184 |
TInt r = fs.Connect();
|
|
1185 |
|
|
1186 |
fs.SetSessionPath(gSessionPath);
|
|
1187 |
|
|
1188 |
r = file.Open(fs, gStreamFile, EFileShareAny|EFileRead);
|
|
1189 |
|
|
1190 |
client.Signal();
|
|
1191 |
|
|
1192 |
FailIfError(r);
|
|
1193 |
r = file.Size(size);
|
|
1194 |
FailIfError(r);
|
|
1195 |
|
|
1196 |
FOREVER
|
|
1197 |
{
|
|
1198 |
startTime.HomeTime();
|
|
1199 |
j = 0;
|
|
1200 |
while(j < (gCurrentSpeed * KOneK))
|
|
1201 |
{
|
|
1202 |
r=file.Read(gBufReadPtr,gCurrentBS);
|
|
1203 |
FailIfError(r);
|
|
1204 |
j += gCurrentBS;
|
|
1205 |
}
|
|
1206 |
endTime.HomeTime();
|
|
1207 |
|
|
1208 |
timeTaken = endTime.MicroSecondsFrom(startTime);
|
|
1209 |
time = I64LOW(timeTaken.Int64());
|
|
1210 |
|
|
1211 |
if(time > KOneSec)
|
|
1212 |
{
|
|
1213 |
test.Printf(_L("Background Thread: Speed failed to be achieved: %d kbps\n"), gCurrentSpeed);
|
|
1214 |
}
|
|
1215 |
|
|
1216 |
|
|
1217 |
|
|
1218 |
timeLeft = KOneSec - time;
|
|
1219 |
User::After(timeLeft);
|
|
1220 |
currentPos += (gCurrentSpeed * KOneK);
|
|
1221 |
r = file.Size(size);
|
|
1222 |
FailIfError(r);
|
|
1223 |
if(currentPos > size )
|
|
1224 |
{
|
|
1225 |
currentPos = 0;
|
|
1226 |
file.Seek(ESeekStart, currentPos);
|
|
1227 |
}
|
|
1228 |
|
|
1229 |
}
|
|
1230 |
|
|
1231 |
}
|
|
1232 |
|
|
1233 |
/** Test case layout, read/write at aSpeed during aWtime and aRTime
|
|
1234 |
|
|
1235 |
@param aSpeed Target speed in kbps
|
|
1236 |
@param aBlockSize Block size for the I/O operation
|
|
1237 |
@param aWTime Writing time
|
|
1238 |
@param aRTime Reading time
|
|
1239 |
*/
|
|
1240 |
LOCAL_C void streamIt ( TInt aSpeed, TInt aBlockSize, TInt aWTime, TInt aRTime, TInt aStep)
|
|
1241 |
{
|
|
1242 |
TInt iSize = (aSpeed * KTobps) / KByte; // Size in bytes
|
|
1243 |
RFile file;
|
|
1244 |
TInt pos = 0;
|
|
1245 |
TInt r = 0;
|
|
1246 |
|
|
1247 |
PrintResult(aStep, 1, aBlockSize);
|
|
1248 |
|
|
1249 |
r = file.Replace(TheFs, gStreamFile, EFileShareAny|EFileWrite);
|
|
1250 |
FailIfError(r);
|
|
1251 |
|
|
1252 |
// Streaming to the media during aWTime seconds
|
|
1253 |
if(writeStr(file, iSize, aBlockSize, aWTime))
|
|
1254 |
{ //Pass (1)
|
|
1255 |
PrintResult(aStep, 2, 1);
|
|
1256 |
}
|
|
1257 |
else
|
|
1258 |
{ //Fail (0)
|
|
1259 |
PrintResult(aStep, 2, 0);
|
|
1260 |
}
|
|
1261 |
|
|
1262 |
// Create a different thread for reading from the beginning during aRTime
|
|
1263 |
TBuf<20> buf = _L("Speedy");
|
|
1264 |
buf.AppendNum(ThreadCount++);
|
|
1265 |
|
|
1266 |
gCurrentSpeed = aSpeed;
|
|
1267 |
gCurrentBS = aBlockSize;
|
|
1268 |
r = gSpeedy.Create(buf, ReadStream, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
1269 |
FailIfError(r);
|
|
1270 |
|
|
1271 |
gSpeedy.Resume();
|
|
1272 |
client.Wait();
|
|
1273 |
|
|
1274 |
// Keep writing during the time the other thread is reading
|
|
1275 |
if(writeStr(file, iSize, aBlockSize, aRTime))
|
|
1276 |
{ //Pass (1)
|
|
1277 |
PrintResult(aStep, 3, 1);
|
|
1278 |
}
|
|
1279 |
else
|
|
1280 |
{ //Fail (0)
|
|
1281 |
PrintResult(aStep, 3, 0);
|
|
1282 |
}
|
|
1283 |
|
|
1284 |
// Writing from the beginning again
|
|
1285 |
file.Seek(ESeekStart, pos);
|
|
1286 |
if(writeStr(file, iSize, aBlockSize, aRTime))
|
|
1287 |
{ //Pass (1)
|
|
1288 |
PrintResult(aStep, 4, 1);
|
|
1289 |
}
|
|
1290 |
else
|
|
1291 |
{ //Fail (0)
|
|
1292 |
PrintResult(aStep, 4, 0);
|
|
1293 |
}
|
|
1294 |
|
|
1295 |
|
|
1296 |
// Kill the thread for reading
|
|
1297 |
gSpeedy.Kill(KErrNone);
|
|
1298 |
FailIfError(r);
|
|
1299 |
gSpeedy.Close();
|
|
1300 |
|
|
1301 |
file.Close();
|
|
1302 |
}
|
|
1303 |
|
|
1304 |
/** Iterating through different blocksizes
|
|
1305 |
|
|
1306 |
@param aSpeed Speed at which the test happens
|
|
1307 |
*/
|
|
1308 |
LOCAL_C void streaming(TInt aSpeed)
|
|
1309 |
{
|
|
1310 |
TInt i = 9; // Pow(i) = 512 bytes
|
|
1311 |
TInt blockSize = 0;
|
|
1312 |
TInt testStep = 1;
|
|
1313 |
|
|
1314 |
while( i < 15 ) // Pow(i) = 16 Kb
|
|
1315 |
{
|
|
1316 |
blockSize = Pow(i) ;
|
|
1317 |
streamIt(aSpeed, blockSize, 5 * 60, 15, testStep++); // 5 minutes writing , then 15 secs reading
|
|
1318 |
i++;
|
|
1319 |
}
|
|
1320 |
}
|
|
1321 |
|
|
1322 |
/** High level test routine. Different test cases executed
|
|
1323 |
|
|
1324 |
@param aSelector Test case configuration in case of manual execution
|
|
1325 |
*/
|
|
1326 |
LOCAL_C TInt TestStreaming(TAny* aSelector)
|
|
1327 |
{
|
|
1328 |
|
|
1329 |
Validate(aSelector);
|
|
1330 |
// Each test case of the suite has an identifyer for parsing purposes of the results
|
|
1331 |
gTestHarness = 9;
|
|
1332 |
gTestCase = 1;
|
|
1333 |
|
|
1334 |
|
|
1335 |
PrintHeaders(5, _L("t_fcachebm. Streaming"));
|
|
1336 |
|
|
1337 |
test.Printf(_L("#~TS_Title_%d,%d: Writing / reading at 100 kbps\n"),
|
|
1338 |
gTestHarness, gTestCase);
|
|
1339 |
|
|
1340 |
streaming(100);
|
|
1341 |
|
|
1342 |
test.Printf(_L("#~TS_Title_%d,%d: Writing / reading at 200 kbps\n"),
|
|
1343 |
gTestHarness, ++gTestCase);
|
|
1344 |
|
|
1345 |
streaming(200);
|
|
1346 |
|
|
1347 |
test.Printf(_L("#~TS_Title_%d,%d: Writing / reading at 500 kbps\n"),
|
|
1348 |
gTestHarness, ++gTestCase);
|
|
1349 |
|
|
1350 |
streaming(500);
|
|
1351 |
|
|
1352 |
|
|
1353 |
DeleteAll(gSessionPath);
|
|
1354 |
|
|
1355 |
// Start the small random reads in the background
|
|
1356 |
CreateFile(gBaseFile, Pow(KSmallCol-1));
|
|
1357 |
|
|
1358 |
TBuf<20> buf=_L("Speedy");
|
|
1359 |
buf.AppendNum(ThreadCount++);
|
|
1360 |
|
|
1361 |
TInt r = gSpeedyII.Create(buf, ReadSmallBase, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
1362 |
FailIfError(r);
|
|
1363 |
|
|
1364 |
gSpeedyII.Resume();
|
|
1365 |
client.Wait();
|
|
1366 |
|
|
1367 |
// Measure the throughput with background activity
|
|
1368 |
test.Printf(_L("#~TS_Title_%d,%d: Writing / reading at 100 kbps, while small reads\n"),
|
|
1369 |
gTestHarness, ++gTestCase);
|
|
1370 |
|
|
1371 |
streaming(100);
|
|
1372 |
|
|
1373 |
test.Printf(_L("#~TS_Title_%d,%d: Writing / reading at 200 kbps, while small reads\n"),
|
|
1374 |
gTestHarness, ++gTestCase);
|
|
1375 |
|
|
1376 |
streaming(200);
|
|
1377 |
|
|
1378 |
test.Printf(_L("#~TS_Title_%d,%d: Writing / reading at 500 kbps, while small reads\n"),
|
|
1379 |
gTestHarness, ++gTestCase);
|
|
1380 |
|
|
1381 |
streaming(500);
|
|
1382 |
|
|
1383 |
// Kill the small random reads and writes
|
|
1384 |
gSpeedyII.Kill(KErrNone);
|
|
1385 |
FailIfError(r);
|
|
1386 |
|
|
1387 |
gSpeedyII.Close();
|
|
1388 |
|
|
1389 |
DeleteAll(gSessionPath);
|
|
1390 |
|
|
1391 |
gTestCase++;
|
|
1392 |
test.Printf(_L("#~TestEnd_%d\n"), gTestHarness);
|
|
1393 |
|
|
1394 |
return(KErrNone);
|
|
1395 |
}
|
|
1396 |
|
|
1397 |
/** It goes automatically through all the options
|
|
1398 |
|
|
1399 |
@param aSelector Configuration in case of manual execution
|
|
1400 |
*/
|
|
1401 |
LOCAL_C TInt TestAll(TAny* aSelector)
|
|
1402 |
{
|
|
1403 |
TestSmall(aSelector);
|
|
1404 |
TestLarge(aSelector);
|
|
1405 |
TestStreaming(aSelector);
|
|
1406 |
|
|
1407 |
return(KErrNone);
|
|
1408 |
}
|
|
1409 |
|
|
1410 |
/** Call all tests
|
|
1411 |
|
|
1412 |
*/
|
|
1413 |
GLDEF_C void CallTestsL()
|
|
1414 |
{
|
|
1415 |
TBuf16<25> temp;
|
|
1416 |
|
|
1417 |
TInt r=client.CreateLocal(0);
|
|
1418 |
FailIfError(r);
|
|
1419 |
|
|
1420 |
// Setting up the environment and creating the needed files
|
|
1421 |
gSessionPath = _L("?:\\F32-TST\\");
|
|
1422 |
gSessionPath[0] = (TText) gDriveToTest;
|
|
1423 |
|
|
1424 |
FileNamesGeneration(temp, 8, 0, 1);
|
|
1425 |
gBaseFile = gSessionPath;
|
|
1426 |
gBaseFile.Append(temp);
|
|
1427 |
|
|
1428 |
FileNamesGeneration(temp, 8, 1, 1);
|
|
1429 |
gFileA = gSessionPath;
|
|
1430 |
gFileA.Append(temp);
|
|
1431 |
|
|
1432 |
FileNamesGeneration(temp, 8, 2, 1);
|
|
1433 |
gFileB = gSessionPath;
|
|
1434 |
gFileB.Append(temp);
|
|
1435 |
|
|
1436 |
FileNamesGeneration(temp, 8, 3, 1);
|
|
1437 |
gStreamFile = gSessionPath;
|
|
1438 |
gStreamFile.Append(temp);
|
|
1439 |
|
|
1440 |
TRAPD(res,gBuf = HBufC8::NewL(256 * KOneK));
|
|
1441 |
test(res == KErrNone && gBuf != NULL);
|
|
1442 |
|
|
1443 |
gBufWritePtr.Set(gBuf->Des());
|
|
1444 |
FillBuffer(gBufWritePtr, 256 * KOneK, 'A');
|
|
1445 |
|
|
1446 |
TRAPD(res2, gBufSec = HBufC8::NewL(256 * KOneK));
|
|
1447 |
test(res2 == KErrNone && gBufSec != NULL);
|
|
1448 |
gBufReadPtr.Set(gBufSec->Des());
|
|
1449 |
|
|
1450 |
TVolumeInfo volInfo;
|
|
1451 |
TInt drive;
|
|
1452 |
|
|
1453 |
r = TheFs.CharToDrive(gDriveToTest,drive);
|
|
1454 |
FailIfError(r);
|
|
1455 |
r = TheFs.Volume(volInfo, drive);
|
|
1456 |
FailIfError(r);
|
|
1457 |
|
|
1458 |
FormatFat(gSessionPath[0]-'A');
|
|
1459 |
TheFs.MkDirAll(gSessionPath);
|
|
1460 |
|
|
1461 |
RThread noisy;
|
|
1462 |
TBuf<20> buf = _L("Noisy");
|
|
1463 |
r = noisy.Create(buf, noise, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
1464 |
FailIfError(r);
|
|
1465 |
|
|
1466 |
noisy.Resume();
|
|
1467 |
|
|
1468 |
CSelectionBox* TheSelector=CSelectionBox::NewL(test.Console());
|
|
1469 |
|
|
1470 |
if(gMode == 0)
|
|
1471 |
{ // Manual
|
|
1472 |
gSessionPath=_L("?:\\");
|
|
1473 |
TCallBack smallOps(TestSmall, TheSelector);
|
|
1474 |
TCallBack largeOps(TestLarge, TheSelector);
|
|
1475 |
TCallBack simulOps(TestStreaming, TheSelector);
|
|
1476 |
TCallBack tAll(TestAll, TheSelector);
|
|
1477 |
TheSelector->AddDriveSelectorL(TheFs);
|
|
1478 |
TheSelector->AddLineL(_L("Small random r/w"), smallOps);
|
|
1479 |
TheSelector->AddLineL(_L("Large conseq r/w"), largeOps);
|
|
1480 |
TheSelector->AddLineL(_L("Streaming"), simulOps);
|
|
1481 |
TheSelector->AddLineL(_L("Execute all options"), tAll);
|
|
1482 |
TheSelector->Run();
|
|
1483 |
}
|
|
1484 |
else
|
|
1485 |
{ // Automatic
|
|
1486 |
TestAll(TheSelector);
|
|
1487 |
}
|
|
1488 |
|
|
1489 |
DeleteAll(gSessionPath);
|
|
1490 |
|
|
1491 |
client.Close();
|
|
1492 |
delete TheSelector;
|
|
1493 |
delete gBuf;
|
|
1494 |
delete gBufSec;
|
|
1495 |
noisy.Kill(KErrNone);
|
|
1496 |
noisy.Close();
|
|
1497 |
}
|