sl@0
|
1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// f32test/bench/t_fsysbm.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#define __E32TEST_EXTENSION__
|
sl@0
|
19 |
|
sl@0
|
20 |
#include <f32file.h>
|
sl@0
|
21 |
#include <e32test.h>
|
sl@0
|
22 |
#include <e32hal.h>
|
sl@0
|
23 |
#include <hal.h>
|
sl@0
|
24 |
#include <e32math.h>
|
sl@0
|
25 |
#include <e32ldr.h>
|
sl@0
|
26 |
#include <e32ldr_private.h>
|
sl@0
|
27 |
#include "t_server.h"
|
sl@0
|
28 |
#include "../../e32test/mmu/d_sharedchunk.h"
|
sl@0
|
29 |
|
sl@0
|
30 |
#define SYMBIAN_TEST_EXTENDED_BUFFER_SIZES // test using a greater number of buffer sizes
|
sl@0
|
31 |
//#define SYMBIAN_TEST_COPY // read from one drive and write to another
|
sl@0
|
32 |
|
sl@0
|
33 |
|
sl@0
|
34 |
GLDEF_D RTest test(_L("File System Benchmarks"));
|
sl@0
|
35 |
|
sl@0
|
36 |
static const TUint K1K = 1024; // 1K
|
sl@0
|
37 |
static const TUint K1M = 1024 * 1024; // 1M
|
sl@0
|
38 |
static const TUint K2M = 2 * K1M; // 2M
|
sl@0
|
39 |
|
sl@0
|
40 |
#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
41 |
const TInt64 KGb = 1 << 30;
|
sl@0
|
42 |
const TInt64 K3GB = 3 * KGb;
|
sl@0
|
43 |
const TInt64 K4GB = 4 * KGb;
|
sl@0
|
44 |
#endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
45 |
|
sl@0
|
46 |
#if defined(__WINS__)
|
sl@0
|
47 |
LOCAL_D TInt KMaxFileSize = 256 * K1K; // 256K
|
sl@0
|
48 |
//LOCAL_D TInt KMaxFileSize = K1M; // 1M
|
sl@0
|
49 |
#else
|
sl@0
|
50 |
//LOCAL_D TInt KMaxFileSize = 256 * K1K; // 256K
|
sl@0
|
51 |
//LOCAL_D TInt KMaxFileSize = K1M; // 1M
|
sl@0
|
52 |
LOCAL_D TInt KMaxFileSize = K2M; // 2M
|
sl@0
|
53 |
#endif
|
sl@0
|
54 |
|
sl@0
|
55 |
const TTimeIntervalMicroSeconds32 KFloatingPointTestTime = 10000000; // 10 seconds
|
sl@0
|
56 |
LOCAL_D const TInt KHeapSize = 0x4000;
|
sl@0
|
57 |
|
sl@0
|
58 |
LOCAL_D TPtr8 DataBuf(NULL, KMaxFileSize,KMaxFileSize);
|
sl@0
|
59 |
LOCAL_D HBufC8* DataBufH = NULL;
|
sl@0
|
60 |
|
sl@0
|
61 |
LOCAL_D RSharedChunkLdd Ldd;
|
sl@0
|
62 |
LOCAL_D RChunk TheChunk;
|
sl@0
|
63 |
LOCAL_D TInt PageSize;
|
sl@0
|
64 |
const TUint ChunkSize = KMaxFileSize;
|
sl@0
|
65 |
|
sl@0
|
66 |
|
sl@0
|
67 |
LOCAL_D RFile File, File2;
|
sl@0
|
68 |
LOCAL_D TChar gDriveToTest2;
|
sl@0
|
69 |
|
sl@0
|
70 |
// if enabled, Read and Write operations are not boundary aligned.
|
sl@0
|
71 |
LOCAL_D TBool gMisalignedReadWrites = EFalse;
|
sl@0
|
72 |
|
sl@0
|
73 |
// read & write caching enabled flags - may be overriden by +/-r +/-w command line switches
|
sl@0
|
74 |
LOCAL_D TBool gReadCachingOn = EFalse;
|
sl@0
|
75 |
LOCAL_D TBool gWriteCachingOn = EFalse;
|
sl@0
|
76 |
|
sl@0
|
77 |
// if enabled, timings are for write AND flush
|
sl@0
|
78 |
LOCAL_D TBool gFlushAfterWrite = ETrue;
|
sl@0
|
79 |
|
sl@0
|
80 |
// if enabled, contiguous shared memory is used for Data buffer
|
sl@0
|
81 |
LOCAL_D TBool gSharedMemory = EFalse;
|
sl@0
|
82 |
|
sl@0
|
83 |
// if enabled, fragmented shared memory is used for Data buffer
|
sl@0
|
84 |
LOCAL_D TBool gFragSharedMemory = EFalse;
|
sl@0
|
85 |
|
sl@0
|
86 |
LOCAL_D TInt gFastCounterFreq;
|
sl@0
|
87 |
|
sl@0
|
88 |
|
sl@0
|
89 |
|
sl@0
|
90 |
LOCAL_C void RecursiveRmDir(const TDesC& aDes)
|
sl@0
|
91 |
//
|
sl@0
|
92 |
// Delete directory contents recursively
|
sl@0
|
93 |
//
|
sl@0
|
94 |
{
|
sl@0
|
95 |
CDir* pD;
|
sl@0
|
96 |
TFileName n=aDes;
|
sl@0
|
97 |
n.Append(_L("*"));
|
sl@0
|
98 |
TInt r=TheFs.GetDir(n,KEntryAttMaskSupported,EDirsLast,pD);
|
sl@0
|
99 |
if (r==KErrNotFound || r==KErrPathNotFound)
|
sl@0
|
100 |
return;
|
sl@0
|
101 |
test(r==KErrNone);
|
sl@0
|
102 |
TInt count=pD->Count();
|
sl@0
|
103 |
TInt i=0;
|
sl@0
|
104 |
while (i<count)
|
sl@0
|
105 |
{
|
sl@0
|
106 |
const TEntry& e=(*pD)[i++];
|
sl@0
|
107 |
if (e.IsDir())
|
sl@0
|
108 |
{
|
sl@0
|
109 |
TFileName dirName;
|
sl@0
|
110 |
dirName.Format(_L("%S%S\\"),&aDes,&e.iName);
|
sl@0
|
111 |
RecursiveRmDir(dirName);
|
sl@0
|
112 |
}
|
sl@0
|
113 |
else
|
sl@0
|
114 |
{
|
sl@0
|
115 |
TFileName fileName;
|
sl@0
|
116 |
fileName.Format(_L("%S%S"),&aDes,&e.iName);
|
sl@0
|
117 |
r=TheFs.Delete(fileName);
|
sl@0
|
118 |
test(r==KErrNone);
|
sl@0
|
119 |
}
|
sl@0
|
120 |
}
|
sl@0
|
121 |
delete pD;
|
sl@0
|
122 |
r=TheFs.RmDir(aDes);
|
sl@0
|
123 |
test(r==KErrNone);
|
sl@0
|
124 |
}
|
sl@0
|
125 |
|
sl@0
|
126 |
|
sl@0
|
127 |
void LOCAL_C ClearSessionDirectory()
|
sl@0
|
128 |
//
|
sl@0
|
129 |
// Delete the contents of F32-TST
|
sl@0
|
130 |
//
|
sl@0
|
131 |
{
|
sl@0
|
132 |
TParse sessionPath;
|
sl@0
|
133 |
TInt r=TheFs.Parse(_L("\\F32-TST\\"),_L(""),sessionPath);
|
sl@0
|
134 |
test(r==KErrNone);
|
sl@0
|
135 |
RecursiveRmDir(sessionPath.FullName());
|
sl@0
|
136 |
r=TheFs.MkDir(sessionPath.FullName());
|
sl@0
|
137 |
test(r==KErrNone);
|
sl@0
|
138 |
}
|
sl@0
|
139 |
|
sl@0
|
140 |
|
sl@0
|
141 |
LOCAL_C void DoTestFileRead(TInt aBlockSize, TInt aFileSize = KMaxFileSize, TBool aReRead = EFalse)
|
sl@0
|
142 |
//
|
sl@0
|
143 |
// Do Read Test
|
sl@0
|
144 |
//
|
sl@0
|
145 |
{
|
sl@0
|
146 |
// Create test data
|
sl@0
|
147 |
// test.Printf(_L("Creating test file..."));
|
sl@0
|
148 |
TInt writeBlockLen = aFileSize > DataBuf.MaxSize() ? DataBuf.MaxSize() : aFileSize;
|
sl@0
|
149 |
DataBuf.SetLength(writeBlockLen);
|
sl@0
|
150 |
#if defined(_DEBUG)
|
sl@0
|
151 |
for (TInt m = 0; m < DataBuf.Length(); m++)
|
sl@0
|
152 |
DataBuf[m] = TText8(m % 256);
|
sl@0
|
153 |
#endif
|
sl@0
|
154 |
// To allow this test to run on a non-preq914 branch :
|
sl@0
|
155 |
enum {EFileWriteDirectIO = 0x00001000};
|
sl@0
|
156 |
TInt r = File.Create(TheFs, _L("READTEST"), EFileStream | EFileWriteDirectIO);
|
sl@0
|
157 |
test(r == KErrNone);
|
sl@0
|
158 |
TInt count = aFileSize / DataBuf.Length();
|
sl@0
|
159 |
while (count--)
|
sl@0
|
160 |
File.Write(DataBuf);
|
sl@0
|
161 |
// test.Printf(_L("done\n"));
|
sl@0
|
162 |
File.Close();
|
sl@0
|
163 |
|
sl@0
|
164 |
enum {EFileReadBuffered = 0x00002000, EFileReadDirectIO = 0x00004000};
|
sl@0
|
165 |
r = File.Open(TheFs, _L("READTEST"), EFileStream | (gReadCachingOn ? EFileReadBuffered : EFileReadDirectIO));
|
sl@0
|
166 |
test(r == KErrNone);
|
sl@0
|
167 |
|
sl@0
|
168 |
// const TInt maxReadCount = aFileSize / aBlockSize;
|
sl@0
|
169 |
TUint functionCalls = 0;
|
sl@0
|
170 |
|
sl@0
|
171 |
#if defined SYMBIAN_TEST_COPY
|
sl@0
|
172 |
// To allow this test to run on a non-preq914 branch :
|
sl@0
|
173 |
enum {EFileWriteDirectIO = 0x00001000};
|
sl@0
|
174 |
TInt r = File2.Replace(TheFs, _L("WRITETEST"), EFileStream | EFileWriteDirectIO);
|
sl@0
|
175 |
test(r == KErrNone);
|
sl@0
|
176 |
#endif
|
sl@0
|
177 |
|
sl@0
|
178 |
TTime startTime(0);
|
sl@0
|
179 |
TTime endTime(0);
|
sl@0
|
180 |
|
sl@0
|
181 |
// we stop after the entire file has been read or after 10 seconds, whichever happens sooner
|
sl@0
|
182 |
RTimer timer;
|
sl@0
|
183 |
timer.CreateLocal();
|
sl@0
|
184 |
TRequestStatus reqStat;
|
sl@0
|
185 |
|
sl@0
|
186 |
|
sl@0
|
187 |
TUint initTicks = 0;
|
sl@0
|
188 |
TUint finalTicks = 0;
|
sl@0
|
189 |
|
sl@0
|
190 |
// if aReRead file is set, then read file twice
|
sl@0
|
191 |
for (TInt n=0; n<(aReRead?2:1); n++)
|
sl@0
|
192 |
{
|
sl@0
|
193 |
functionCalls = 0;
|
sl@0
|
194 |
|
sl@0
|
195 |
const TInt readLen = (aReRead && n == 0) ? writeBlockLen : aBlockSize;
|
sl@0
|
196 |
const TInt maxReadCount = aFileSize / readLen;
|
sl@0
|
197 |
|
sl@0
|
198 |
TInt pos = 0;
|
sl@0
|
199 |
File.Seek(ESeekStart, pos);
|
sl@0
|
200 |
|
sl@0
|
201 |
timer.After(reqStat, 10000000); // After 10 secs
|
sl@0
|
202 |
startTime.HomeTime();
|
sl@0
|
203 |
initTicks = User::FastCounter();
|
sl@0
|
204 |
|
sl@0
|
205 |
for (TInt i = 0; i<maxReadCount && reqStat==KRequestPending; i++)
|
sl@0
|
206 |
{
|
sl@0
|
207 |
// test.Printf(_L("Read %d\n"),i);
|
sl@0
|
208 |
// for (TInt a = 0; a < 512; a++)
|
sl@0
|
209 |
// test.Printf(_L("%d"),DataBuf[a]);
|
sl@0
|
210 |
|
sl@0
|
211 |
TInt r = File.Read(DataBuf, readLen);
|
sl@0
|
212 |
test (r == KErrNone);
|
sl@0
|
213 |
|
sl@0
|
214 |
if (DataBuf.Length() == 0)
|
sl@0
|
215 |
break;
|
sl@0
|
216 |
|
sl@0
|
217 |
#if defined SYMBIAN_TEST_COPY
|
sl@0
|
218 |
r = File2.Write(DataBuf, readLen);
|
sl@0
|
219 |
test (r == KErrNone);
|
sl@0
|
220 |
#endif
|
sl@0
|
221 |
functionCalls++;
|
sl@0
|
222 |
|
sl@0
|
223 |
#if defined(_DEBUG)
|
sl@0
|
224 |
// for (TInt a = 0; a < 512; a++)
|
sl@0
|
225 |
// test.Printf(_L("%d"),DataBuf[a]);
|
sl@0
|
226 |
|
sl@0
|
227 |
for (TInt j = 0; j < DataBuf.Size(); j++)
|
sl@0
|
228 |
test(DataBuf[j] == (j + i * readLen) % 256);
|
sl@0
|
229 |
#endif
|
sl@0
|
230 |
|
sl@0
|
231 |
}
|
sl@0
|
232 |
|
sl@0
|
233 |
finalTicks = User::FastCounter();
|
sl@0
|
234 |
endTime.HomeTime();
|
sl@0
|
235 |
timer.Cancel();
|
sl@0
|
236 |
}
|
sl@0
|
237 |
|
sl@0
|
238 |
TInt dataTransferred = functionCalls * aBlockSize;
|
sl@0
|
239 |
|
sl@0
|
240 |
// TTimeIntervalMicroSeconds duration = endTime.MicroSecondsFrom(startTime);
|
sl@0
|
241 |
TTimeIntervalMicroSeconds duration = TInt64(finalTicks - initTicks) * TInt64(1000000) / TInt64(gFastCounterFreq) ;
|
sl@0
|
242 |
|
sl@0
|
243 |
TReal transferRate =
|
sl@0
|
244 |
TReal32(dataTransferred) /
|
sl@0
|
245 |
TReal(duration.Int64()) * TReal(1000000) / TReal(K1K); // KB/s
|
sl@0
|
246 |
test.Printf(_L("Read %7d bytes in %7d byte blocks:\t%11.3f KBytes/s (%d microsecs)\n"),
|
sl@0
|
247 |
dataTransferred, aBlockSize, transferRate, endTime.MicroSecondsFrom(startTime).Int64());
|
sl@0
|
248 |
|
sl@0
|
249 |
|
sl@0
|
250 |
timer.Close();
|
sl@0
|
251 |
#if defined SYMBIAN_TEST_COPY
|
sl@0
|
252 |
File2.Close();
|
sl@0
|
253 |
#endif
|
sl@0
|
254 |
|
sl@0
|
255 |
File.Close();
|
sl@0
|
256 |
r = TheFs.Delete(_L("READTEST"));
|
sl@0
|
257 |
test(r == KErrNone);
|
sl@0
|
258 |
return;
|
sl@0
|
259 |
}
|
sl@0
|
260 |
|
sl@0
|
261 |
|
sl@0
|
262 |
LOCAL_C void TestFileRead(TInt aFileSize = KMaxFileSize, TBool aMisalignedReadWrites = EFalse, TBool aReRead = EFalse)
|
sl@0
|
263 |
//
|
sl@0
|
264 |
// Benchmark read method
|
sl@0
|
265 |
//
|
sl@0
|
266 |
{
|
sl@0
|
267 |
ClearSessionDirectory();
|
sl@0
|
268 |
test.Next(_L("Benchmark read method"));
|
sl@0
|
269 |
|
sl@0
|
270 |
_LIT(KLitReadOnce,"Read-once");
|
sl@0
|
271 |
_LIT(KLitReRead,"Re-read");
|
sl@0
|
272 |
test.Printf(_L("FileSize %d, MisalignedReadWrites %d %S\n"), aFileSize, aMisalignedReadWrites, aReRead ? &KLitReRead : &KLitReadOnce);
|
sl@0
|
273 |
TInt misalignedOffset = aMisalignedReadWrites ? 1 : 0;
|
sl@0
|
274 |
|
sl@0
|
275 |
#if defined (SYMBIAN_TEST_EXTENDED_BUFFER_SIZES)
|
sl@0
|
276 |
DoTestFileRead(1+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
277 |
DoTestFileRead(2+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
278 |
DoTestFileRead(4+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
279 |
DoTestFileRead(8+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
280 |
DoTestFileRead(16+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
281 |
DoTestFileRead(32+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
282 |
DoTestFileRead(64+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
283 |
DoTestFileRead(128+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
284 |
DoTestFileRead(256+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
285 |
DoTestFileRead(512+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
286 |
DoTestFileRead(1024+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
287 |
DoTestFileRead(2 * 1024+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
288 |
DoTestFileRead(4 * 1024+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
289 |
DoTestFileRead(8 * 1024+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
290 |
DoTestFileRead(16 * 1024+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
291 |
DoTestFileRead(32 * 1024+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
292 |
DoTestFileRead(64 * 1024+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
293 |
DoTestFileRead(128 * 1024+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
294 |
DoTestFileRead(256 * 1024+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
295 |
DoTestFileRead(512 * 1024+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
296 |
DoTestFileRead(1024 * 1024+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
297 |
#else
|
sl@0
|
298 |
DoTestFileRead(16+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
299 |
DoTestFileRead(512+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
300 |
DoTestFileRead(4096+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
301 |
DoTestFileRead(32768+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
302 |
DoTestFileRead(64 * 1024+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
303 |
DoTestFileRead(K1M+misalignedOffset, aFileSize, aReRead);
|
sl@0
|
304 |
#endif
|
sl@0
|
305 |
|
sl@0
|
306 |
}
|
sl@0
|
307 |
|
sl@0
|
308 |
|
sl@0
|
309 |
LOCAL_C TInt FloatingPointLoop(TAny* funcCount)
|
sl@0
|
310 |
{
|
sl@0
|
311 |
TUint& count = *(TUint*) funcCount;
|
sl@0
|
312 |
TReal eq = KPi;
|
sl@0
|
313 |
|
sl@0
|
314 |
FOREVER
|
sl@0
|
315 |
{
|
sl@0
|
316 |
eq *= eq;
|
sl@0
|
317 |
count++;
|
sl@0
|
318 |
}
|
sl@0
|
319 |
|
sl@0
|
320 |
}
|
sl@0
|
321 |
|
sl@0
|
322 |
|
sl@0
|
323 |
LOCAL_C void DoTestFileReadCPU(TInt aBlockSize)
|
sl@0
|
324 |
//
|
sl@0
|
325 |
// Benchmark CPU utilisation for Read method
|
sl@0
|
326 |
//
|
sl@0
|
327 |
// Read operations are performed for 10 seconds whilst a second thread executes floating point calculations
|
sl@0
|
328 |
// The higher the number of calculations the less amount of CPU time has been used by the Read method.
|
sl@0
|
329 |
//
|
sl@0
|
330 |
{
|
sl@0
|
331 |
enum {EFileReadBuffered = 0x00002000, EFileReadDirectIO = 0x00004000};
|
sl@0
|
332 |
TInt r = File.Open(TheFs, _L("READCPUTEST"), EFileStream | (gReadCachingOn ? EFileReadBuffered : EFileReadDirectIO));
|
sl@0
|
333 |
test(r == KErrNone);
|
sl@0
|
334 |
|
sl@0
|
335 |
TInt pos = 0;
|
sl@0
|
336 |
|
sl@0
|
337 |
TUint functionCalls = 0;
|
sl@0
|
338 |
TUint fltPntCalls = 0;
|
sl@0
|
339 |
RThread fltPntThrd;
|
sl@0
|
340 |
|
sl@0
|
341 |
TBuf<6> buf = _L("Floaty");
|
sl@0
|
342 |
fltPntThrd.Create(buf, FloatingPointLoop, KDefaultStackSize, KHeapSize, KHeapSize, (TAny*) &fltPntCalls);
|
sl@0
|
343 |
|
sl@0
|
344 |
RTimer timer;
|
sl@0
|
345 |
timer.CreateLocal();
|
sl@0
|
346 |
TRequestStatus reqStat;
|
sl@0
|
347 |
|
sl@0
|
348 |
TUint initTicks = 0;
|
sl@0
|
349 |
TUint finalTicks = 0;
|
sl@0
|
350 |
|
sl@0
|
351 |
timer.After(reqStat, KFloatingPointTestTime); // After 10 secs
|
sl@0
|
352 |
initTicks = User::FastCounter();
|
sl@0
|
353 |
|
sl@0
|
354 |
// up the priority of this thread so that we only run the floating point thread when this thread is idle
|
sl@0
|
355 |
RThread thisThread;
|
sl@0
|
356 |
thisThread.SetPriority(EPriorityMuchMore);
|
sl@0
|
357 |
|
sl@0
|
358 |
TRequestStatus req;
|
sl@0
|
359 |
fltPntThrd.Logon(req);
|
sl@0
|
360 |
|
sl@0
|
361 |
fltPntThrd.Resume();
|
sl@0
|
362 |
|
sl@0
|
363 |
for (TInt i = 0; reqStat==KRequestPending; i++)
|
sl@0
|
364 |
{
|
sl@0
|
365 |
TInt r = File.Read(pos, DataBuf, aBlockSize);
|
sl@0
|
366 |
test (r == KErrNone);
|
sl@0
|
367 |
|
sl@0
|
368 |
pos += aBlockSize;
|
sl@0
|
369 |
if (pos > KMaxFileSize-aBlockSize)
|
sl@0
|
370 |
pos = 0;
|
sl@0
|
371 |
|
sl@0
|
372 |
functionCalls++;
|
sl@0
|
373 |
}
|
sl@0
|
374 |
|
sl@0
|
375 |
TUint fltPntCallsFinal = fltPntCalls;
|
sl@0
|
376 |
fltPntThrd.Kill(KErrNone);
|
sl@0
|
377 |
|
sl@0
|
378 |
finalTicks = User::FastCounter();
|
sl@0
|
379 |
|
sl@0
|
380 |
fltPntThrd.Close();
|
sl@0
|
381 |
User::WaitForRequest(req);
|
sl@0
|
382 |
|
sl@0
|
383 |
TInt dataTransferred = functionCalls * aBlockSize;
|
sl@0
|
384 |
|
sl@0
|
385 |
TTimeIntervalMicroSeconds duration = TInt64(finalTicks - initTicks) * TInt64(1000000) / TInt64(gFastCounterFreq) ;
|
sl@0
|
386 |
|
sl@0
|
387 |
TReal transferRate = TReal32(dataTransferred) /
|
sl@0
|
388 |
TReal(duration.Int64()) * TReal(1000000) / TReal(K1K); // KB/s
|
sl@0
|
389 |
|
sl@0
|
390 |
test.Printf(_L("Read %7d bytes in %7d byte blocks:\t%11.3f KBytes/s; %d Flt Calcs\n"),
|
sl@0
|
391 |
dataTransferred, aBlockSize, transferRate, fltPntCallsFinal);
|
sl@0
|
392 |
|
sl@0
|
393 |
timer.Close();
|
sl@0
|
394 |
|
sl@0
|
395 |
File.Close();
|
sl@0
|
396 |
|
sl@0
|
397 |
return;
|
sl@0
|
398 |
}
|
sl@0
|
399 |
|
sl@0
|
400 |
|
sl@0
|
401 |
LOCAL_C void TestFileReadCPU(TBool aMisalignedReadWrites = EFalse)
|
sl@0
|
402 |
//
|
sl@0
|
403 |
// Benchmark CPU utilisation for Read method
|
sl@0
|
404 |
//
|
sl@0
|
405 |
{
|
sl@0
|
406 |
ClearSessionDirectory();
|
sl@0
|
407 |
test.Next(_L("Benchmark Read method CPU Utilisation"));
|
sl@0
|
408 |
|
sl@0
|
409 |
test.Printf(_L("MisalignedReadWrites %d\n"), aMisalignedReadWrites);
|
sl@0
|
410 |
TInt misalignedOffset = aMisalignedReadWrites ? 1 : 0;
|
sl@0
|
411 |
|
sl@0
|
412 |
// Create test data
|
sl@0
|
413 |
test.Printf(_L("Creating test file..."));
|
sl@0
|
414 |
DataBuf.SetLength(KMaxFileSize);
|
sl@0
|
415 |
|
sl@0
|
416 |
TInt r = File.Create(TheFs, _L("READCPUTEST"), EFileStream | EFileWriteDirectIO);
|
sl@0
|
417 |
test(r == KErrNone);
|
sl@0
|
418 |
|
sl@0
|
419 |
File.Write(DataBuf);
|
sl@0
|
420 |
|
sl@0
|
421 |
test.Printf(_L("done\n"));
|
sl@0
|
422 |
File.Close();
|
sl@0
|
423 |
|
sl@0
|
424 |
DoTestFileReadCPU(1+misalignedOffset);
|
sl@0
|
425 |
DoTestFileReadCPU(2+misalignedOffset);
|
sl@0
|
426 |
DoTestFileReadCPU(4+misalignedOffset);
|
sl@0
|
427 |
DoTestFileReadCPU(8+misalignedOffset);
|
sl@0
|
428 |
DoTestFileReadCPU(16+misalignedOffset);
|
sl@0
|
429 |
DoTestFileReadCPU(32+misalignedOffset);
|
sl@0
|
430 |
DoTestFileReadCPU(64+misalignedOffset);
|
sl@0
|
431 |
DoTestFileReadCPU(128+misalignedOffset);
|
sl@0
|
432 |
DoTestFileReadCPU(256+misalignedOffset);
|
sl@0
|
433 |
DoTestFileReadCPU(512+misalignedOffset);
|
sl@0
|
434 |
DoTestFileReadCPU(1024+misalignedOffset);
|
sl@0
|
435 |
DoTestFileReadCPU(2 * 1024+misalignedOffset);
|
sl@0
|
436 |
DoTestFileReadCPU(4 * 1024+misalignedOffset);
|
sl@0
|
437 |
DoTestFileReadCPU(8 * 1024+misalignedOffset);
|
sl@0
|
438 |
DoTestFileReadCPU(16 * 1024+misalignedOffset);
|
sl@0
|
439 |
DoTestFileReadCPU(32 * 1024+misalignedOffset);
|
sl@0
|
440 |
DoTestFileReadCPU(64 * 1024+misalignedOffset);
|
sl@0
|
441 |
DoTestFileReadCPU(128 * 1024+misalignedOffset);
|
sl@0
|
442 |
DoTestFileReadCPU(256 * 1024+misalignedOffset);
|
sl@0
|
443 |
DoTestFileReadCPU(512 * 1024+misalignedOffset);
|
sl@0
|
444 |
DoTestFileReadCPU(K1M+misalignedOffset);
|
sl@0
|
445 |
|
sl@0
|
446 |
|
sl@0
|
447 |
r = TheFs.Delete(_L("READCPUTEST"));
|
sl@0
|
448 |
test(r == KErrNone);
|
sl@0
|
449 |
}
|
sl@0
|
450 |
|
sl@0
|
451 |
|
sl@0
|
452 |
LOCAL_C void DoTestFileWrite(TInt aBlockSize, TInt aFileSize = KMaxFileSize, TBool aUpdate = EFalse)
|
sl@0
|
453 |
//
|
sl@0
|
454 |
// Do Write benchmark
|
sl@0
|
455 |
//
|
sl@0
|
456 |
{
|
sl@0
|
457 |
DataBuf.SetLength(aBlockSize);
|
sl@0
|
458 |
const TInt maxWriteCount = aFileSize / aBlockSize;
|
sl@0
|
459 |
|
sl@0
|
460 |
TFileName testDir(_L("?:\\F32-TST\\"));
|
sl@0
|
461 |
testDir[0] = (TText) gDriveToTest;
|
sl@0
|
462 |
TInt r = TheFs.MkDir(testDir);
|
sl@0
|
463 |
test(r == KErrNone || r == KErrAlreadyExists);
|
sl@0
|
464 |
|
sl@0
|
465 |
TFileName fileName;
|
sl@0
|
466 |
enum {EFileWriteDirectIO = 0x00001000, EFileWriteBuffered = 0x00000800};
|
sl@0
|
467 |
r = File.Temp(TheFs, testDir, fileName, EFileWrite | (gWriteCachingOn ? EFileWriteBuffered : EFileWriteDirectIO));
|
sl@0
|
468 |
test(r == KErrNone);
|
sl@0
|
469 |
|
sl@0
|
470 |
if (aUpdate)
|
sl@0
|
471 |
{
|
sl@0
|
472 |
TInt r = File.SetSize(aFileSize);
|
sl@0
|
473 |
test(r == KErrNone);
|
sl@0
|
474 |
}
|
sl@0
|
475 |
|
sl@0
|
476 |
TUint functionCalls = 0;
|
sl@0
|
477 |
|
sl@0
|
478 |
TTime startTime;
|
sl@0
|
479 |
TTime endTime;
|
sl@0
|
480 |
TUint initTicks = 0;
|
sl@0
|
481 |
TUint finalTicks = 0;
|
sl@0
|
482 |
|
sl@0
|
483 |
|
sl@0
|
484 |
// we stop after the entire file has been written or after 10 seconds, whichever happens sooner
|
sl@0
|
485 |
RTimer timer;
|
sl@0
|
486 |
timer.CreateLocal();
|
sl@0
|
487 |
TRequestStatus reqStat;
|
sl@0
|
488 |
|
sl@0
|
489 |
TInt pos = 0;
|
sl@0
|
490 |
File.Seek(ESeekStart, pos);
|
sl@0
|
491 |
|
sl@0
|
492 |
timer.After(reqStat, 10000000); // After 10 secs
|
sl@0
|
493 |
|
sl@0
|
494 |
startTime.HomeTime();
|
sl@0
|
495 |
initTicks = User::FastCounter();
|
sl@0
|
496 |
|
sl@0
|
497 |
for (TInt i = 0 ; i<maxWriteCount && reqStat==KRequestPending; i++)
|
sl@0
|
498 |
{
|
sl@0
|
499 |
File.Write(pos, DataBuf, aBlockSize);
|
sl@0
|
500 |
|
sl@0
|
501 |
pos += aBlockSize;
|
sl@0
|
502 |
if (pos > KMaxFileSize-aBlockSize)
|
sl@0
|
503 |
pos = 0;
|
sl@0
|
504 |
|
sl@0
|
505 |
functionCalls++;
|
sl@0
|
506 |
}
|
sl@0
|
507 |
|
sl@0
|
508 |
if (gFlushAfterWrite)
|
sl@0
|
509 |
{
|
sl@0
|
510 |
r = File.Flush();
|
sl@0
|
511 |
test_KErrNone(r)
|
sl@0
|
512 |
}
|
sl@0
|
513 |
|
sl@0
|
514 |
// write file once only
|
sl@0
|
515 |
finalTicks = User::FastCounter();
|
sl@0
|
516 |
endTime.HomeTime();
|
sl@0
|
517 |
// TTimeIntervalMicroSeconds duration = endTime.MicroSecondsFrom(startTime);
|
sl@0
|
518 |
TTimeIntervalMicroSeconds duration = TInt64(finalTicks - initTicks) * TInt64(1000000) / TInt64(gFastCounterFreq) ;
|
sl@0
|
519 |
|
sl@0
|
520 |
TInt dataTransferred = functionCalls * aBlockSize;
|
sl@0
|
521 |
TReal transferRate =
|
sl@0
|
522 |
TReal32(dataTransferred) /
|
sl@0
|
523 |
TReal(duration.Int64()) * TReal(1000000) / TReal(K1K); // KB/s
|
sl@0
|
524 |
test.Printf(_L("Write %7d bytes in %7d byte blocks:\t%11.3f KBytes/s (%d microsecs)\n"),
|
sl@0
|
525 |
dataTransferred, aBlockSize, transferRate, endTime.MicroSecondsFrom(startTime).Int64());
|
sl@0
|
526 |
|
sl@0
|
527 |
timer.Close();
|
sl@0
|
528 |
|
sl@0
|
529 |
File.Close();
|
sl@0
|
530 |
r = TheFs.Delete(fileName);
|
sl@0
|
531 |
test_KErrNone(r)
|
sl@0
|
532 |
|
sl@0
|
533 |
return;
|
sl@0
|
534 |
}
|
sl@0
|
535 |
|
sl@0
|
536 |
|
sl@0
|
537 |
LOCAL_C void TestFileWrite(TInt aFileSize = KMaxFileSize, TBool aMisalignedReadWrites = EFalse, TBool aUpdate = EFalse)
|
sl@0
|
538 |
//
|
sl@0
|
539 |
// Benchmark write method
|
sl@0
|
540 |
//
|
sl@0
|
541 |
{
|
sl@0
|
542 |
ClearSessionDirectory();
|
sl@0
|
543 |
test.Next(_L("Benchmark write method"));
|
sl@0
|
544 |
|
sl@0
|
545 |
_LIT(KLitUpdate,"update");
|
sl@0
|
546 |
_LIT(KLitAppend,"append");
|
sl@0
|
547 |
test.Printf(_L("FileSize %d %S MisalignedReadWrites %d\n"), aFileSize, aUpdate? &KLitUpdate : &KLitAppend, aMisalignedReadWrites);
|
sl@0
|
548 |
|
sl@0
|
549 |
TInt misalignedOffset = aMisalignedReadWrites ? 1 : 0;
|
sl@0
|
550 |
|
sl@0
|
551 |
#if defined (SYMBIAN_TEST_EXTENDED_BUFFER_SIZES)
|
sl@0
|
552 |
DoTestFileWrite(1+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
553 |
DoTestFileWrite(2+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
554 |
DoTestFileWrite(4+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
555 |
DoTestFileWrite(8+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
556 |
DoTestFileWrite(16+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
557 |
DoTestFileWrite(32+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
558 |
DoTestFileWrite(64+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
559 |
DoTestFileWrite(128+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
560 |
DoTestFileWrite(256+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
561 |
DoTestFileWrite(512+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
562 |
DoTestFileWrite(1024+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
563 |
DoTestFileWrite(2 * 1024+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
564 |
DoTestFileWrite(4 * 1024+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
565 |
DoTestFileWrite(8 * 1024+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
566 |
DoTestFileWrite(16 * 1024+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
567 |
DoTestFileWrite(32 * 1024+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
568 |
DoTestFileWrite(64 * 1024+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
569 |
DoTestFileWrite(128 * 1024+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
570 |
DoTestFileWrite(256 * 1024+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
571 |
DoTestFileWrite(512 * 1024+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
572 |
DoTestFileWrite(1024 * 1024+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
573 |
#else
|
sl@0
|
574 |
DoTestFileWrite(16+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
575 |
DoTestFileWrite(512+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
576 |
DoTestFileWrite(4096+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
577 |
DoTestFileWrite(32768+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
578 |
DoTestFileWrite(64 * 1024+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
579 |
DoTestFileWrite(K1M+misalignedOffset, aFileSize, aUpdate);
|
sl@0
|
580 |
#endif
|
sl@0
|
581 |
}
|
sl@0
|
582 |
|
sl@0
|
583 |
|
sl@0
|
584 |
|
sl@0
|
585 |
LOCAL_C void DoTestFileWriteCPU(TInt aBlockSize)
|
sl@0
|
586 |
//
|
sl@0
|
587 |
// Benchmark CPU utilisation for Write method
|
sl@0
|
588 |
//
|
sl@0
|
589 |
// Write operations are performed for 10 seconds whilst a second thread executes floating point calculations
|
sl@0
|
590 |
// The higher the number of calculations the less amount of CPU time has been used by the Write method.
|
sl@0
|
591 |
//
|
sl@0
|
592 |
{
|
sl@0
|
593 |
DataBuf.SetLength(aBlockSize);
|
sl@0
|
594 |
|
sl@0
|
595 |
TFileName testDir(_L("?:\\F32-TST\\"));
|
sl@0
|
596 |
testDir[0] = (TText) gDriveToTest;
|
sl@0
|
597 |
TInt r = TheFs.MkDir(testDir);
|
sl@0
|
598 |
test(r == KErrNone || r == KErrAlreadyExists);
|
sl@0
|
599 |
|
sl@0
|
600 |
TFileName fileName;
|
sl@0
|
601 |
enum {EFileWriteDirectIO = 0x00001000, EFileWriteBuffered = 0x00000800};
|
sl@0
|
602 |
r = File.Temp(TheFs, testDir, fileName, EFileWrite | (gWriteCachingOn ? EFileWriteBuffered : EFileWriteDirectIO));
|
sl@0
|
603 |
test(r == KErrNone);
|
sl@0
|
604 |
|
sl@0
|
605 |
TUint functionCalls = 0;
|
sl@0
|
606 |
TUint fltPntCalls = 0;
|
sl@0
|
607 |
RThread fltPntThrd;
|
sl@0
|
608 |
|
sl@0
|
609 |
TBuf<6> buf = _L("Floaty");
|
sl@0
|
610 |
fltPntThrd.Create(buf, FloatingPointLoop, KDefaultStackSize, KHeapSize, KHeapSize, (TAny*) &fltPntCalls);
|
sl@0
|
611 |
|
sl@0
|
612 |
TUint initTicks = 0;
|
sl@0
|
613 |
TUint finalTicks = 0;
|
sl@0
|
614 |
|
sl@0
|
615 |
// up the priority of this thread so that we only run the floating point thread when this thread is idle
|
sl@0
|
616 |
RThread thisThread;
|
sl@0
|
617 |
thisThread.SetPriority(EPriorityMuchMore);
|
sl@0
|
618 |
|
sl@0
|
619 |
TRequestStatus req;
|
sl@0
|
620 |
fltPntThrd.Logon(req);
|
sl@0
|
621 |
|
sl@0
|
622 |
RTimer timer;
|
sl@0
|
623 |
timer.CreateLocal();
|
sl@0
|
624 |
TRequestStatus reqStat;
|
sl@0
|
625 |
|
sl@0
|
626 |
TInt pos = 0;
|
sl@0
|
627 |
File.Seek(ESeekStart, pos);
|
sl@0
|
628 |
|
sl@0
|
629 |
timer.After(reqStat, KFloatingPointTestTime);
|
sl@0
|
630 |
initTicks = User::FastCounter();
|
sl@0
|
631 |
|
sl@0
|
632 |
fltPntThrd.Resume();
|
sl@0
|
633 |
|
sl@0
|
634 |
for (TInt i = 0 ; reqStat==KRequestPending; i++)
|
sl@0
|
635 |
{
|
sl@0
|
636 |
File.Write(DataBuf, aBlockSize);
|
sl@0
|
637 |
functionCalls++;
|
sl@0
|
638 |
}
|
sl@0
|
639 |
TUint fltPntCallsFinal = fltPntCalls;
|
sl@0
|
640 |
|
sl@0
|
641 |
fltPntThrd.Kill(KErrNone);
|
sl@0
|
642 |
|
sl@0
|
643 |
finalTicks = User::FastCounter();
|
sl@0
|
644 |
|
sl@0
|
645 |
fltPntThrd.Close();
|
sl@0
|
646 |
User::WaitForRequest(req);
|
sl@0
|
647 |
|
sl@0
|
648 |
TTimeIntervalMicroSeconds duration = TInt64(finalTicks - initTicks) * TInt64(1000000) / TInt64(gFastCounterFreq) ;
|
sl@0
|
649 |
|
sl@0
|
650 |
TInt dataTransferred = functionCalls * aBlockSize;
|
sl@0
|
651 |
TReal transferRate = TReal32(dataTransferred) /
|
sl@0
|
652 |
TReal(duration.Int64()) * TReal(1000000) / TReal(K1K); // KB/s
|
sl@0
|
653 |
|
sl@0
|
654 |
test.Printf(_L("Write %7d bytes in %7d byte blocks:\t%11.3f KBytes/s; %d Flt Calcs\n"),
|
sl@0
|
655 |
dataTransferred, aBlockSize, transferRate, fltPntCallsFinal);
|
sl@0
|
656 |
|
sl@0
|
657 |
timer.Close();
|
sl@0
|
658 |
|
sl@0
|
659 |
File.Close();
|
sl@0
|
660 |
r = TheFs.Delete(fileName);
|
sl@0
|
661 |
test_KErrNone(r)
|
sl@0
|
662 |
|
sl@0
|
663 |
return;
|
sl@0
|
664 |
}
|
sl@0
|
665 |
|
sl@0
|
666 |
|
sl@0
|
667 |
LOCAL_C void TestFileWriteCPU(TBool aMisalignedReadWrites = EFalse)
|
sl@0
|
668 |
//
|
sl@0
|
669 |
// Benchmark CPU utilisation for Write method
|
sl@0
|
670 |
//
|
sl@0
|
671 |
{
|
sl@0
|
672 |
ClearSessionDirectory();
|
sl@0
|
673 |
test.Next(_L("Benchmark Write method CPU Utilisation"));
|
sl@0
|
674 |
|
sl@0
|
675 |
test.Printf(_L("MisalignedReadWrites %d\n"), aMisalignedReadWrites);
|
sl@0
|
676 |
TInt misalignedOffset = aMisalignedReadWrites ? 1 : 0;
|
sl@0
|
677 |
|
sl@0
|
678 |
DoTestFileWriteCPU(1+misalignedOffset);
|
sl@0
|
679 |
DoTestFileWriteCPU(2+misalignedOffset);
|
sl@0
|
680 |
DoTestFileWriteCPU(4+misalignedOffset);
|
sl@0
|
681 |
DoTestFileWriteCPU(8+misalignedOffset);
|
sl@0
|
682 |
DoTestFileWriteCPU(16+misalignedOffset);
|
sl@0
|
683 |
DoTestFileWriteCPU(32+misalignedOffset);
|
sl@0
|
684 |
DoTestFileWriteCPU(64+misalignedOffset);
|
sl@0
|
685 |
DoTestFileWriteCPU(128+misalignedOffset);
|
sl@0
|
686 |
DoTestFileWriteCPU(256+misalignedOffset);
|
sl@0
|
687 |
DoTestFileWriteCPU(512+misalignedOffset);
|
sl@0
|
688 |
DoTestFileWriteCPU(1024+misalignedOffset);
|
sl@0
|
689 |
DoTestFileWriteCPU(2 * 1024+misalignedOffset);
|
sl@0
|
690 |
DoTestFileWriteCPU(4 * 1024+misalignedOffset);
|
sl@0
|
691 |
DoTestFileWriteCPU(8 * 1024+misalignedOffset);
|
sl@0
|
692 |
DoTestFileWriteCPU(16 * 1024+misalignedOffset);
|
sl@0
|
693 |
DoTestFileWriteCPU(32 * 1024+misalignedOffset);
|
sl@0
|
694 |
DoTestFileWriteCPU(64 * 1024+misalignedOffset);
|
sl@0
|
695 |
DoTestFileWriteCPU(128 * 1024+misalignedOffset);
|
sl@0
|
696 |
DoTestFileWriteCPU(256 * 1024+misalignedOffset);
|
sl@0
|
697 |
DoTestFileWriteCPU(512 * 1024+misalignedOffset);
|
sl@0
|
698 |
DoTestFileWriteCPU(K1M+misalignedOffset);
|
sl@0
|
699 |
}
|
sl@0
|
700 |
|
sl@0
|
701 |
|
sl@0
|
702 |
LOCAL_C void TestFileSeek()
|
sl@0
|
703 |
//
|
sl@0
|
704 |
// Benchmark file seek method
|
sl@0
|
705 |
//
|
sl@0
|
706 |
{
|
sl@0
|
707 |
ClearSessionDirectory();
|
sl@0
|
708 |
test.Next(_L("RFile::Seek method"));
|
sl@0
|
709 |
TInt increment=1789; // random number > cluster size
|
sl@0
|
710 |
TInt count=0;
|
sl@0
|
711 |
TInt pos=0;
|
sl@0
|
712 |
|
sl@0
|
713 |
// Create test file
|
sl@0
|
714 |
TBuf8<1024> testdata(1024);
|
sl@0
|
715 |
RFile f;
|
sl@0
|
716 |
TInt r=f.Create(TheFs,_L("SEEKTEST"),EFileStream);
|
sl@0
|
717 |
test(r==KErrNone);
|
sl@0
|
718 |
count=64;
|
sl@0
|
719 |
while (count--)
|
sl@0
|
720 |
f.Write(testdata);
|
sl@0
|
721 |
TInt fileSize=count*testdata.MaxLength();
|
sl@0
|
722 |
|
sl@0
|
723 |
pos=0;
|
sl@0
|
724 |
count=0;
|
sl@0
|
725 |
RTimer timer;
|
sl@0
|
726 |
timer.CreateLocal();
|
sl@0
|
727 |
TRequestStatus reqStat;
|
sl@0
|
728 |
timer.After(reqStat,10000000); // After 10 secs
|
sl@0
|
729 |
while(reqStat==KRequestPending)
|
sl@0
|
730 |
{
|
sl@0
|
731 |
TInt dum=(pos+=increment)%fileSize;
|
sl@0
|
732 |
f.Seek(ESeekStart,dum);
|
sl@0
|
733 |
count++;
|
sl@0
|
734 |
}
|
sl@0
|
735 |
test.Printf(_L("RFile::Seek operations in 10 secs == %d\n"),count);
|
sl@0
|
736 |
timer.Close();
|
sl@0
|
737 |
|
sl@0
|
738 |
f.Close();
|
sl@0
|
739 |
TheFs.Delete(_L("SEEKTEST"));
|
sl@0
|
740 |
}
|
sl@0
|
741 |
|
sl@0
|
742 |
#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
743 |
|
sl@0
|
744 |
LOCAL_C void CreateManyLargFiles(TInt aNumber)
|
sl@0
|
745 |
//
|
sl@0
|
746 |
// Make a directory with aNumber entries
|
sl@0
|
747 |
//
|
sl@0
|
748 |
{
|
sl@0
|
749 |
RFile64 f;
|
sl@0
|
750 |
TInt maxEntry=aNumber;
|
sl@0
|
751 |
|
sl@0
|
752 |
test.Printf(_L("Create a directory with %d entries\n"),aNumber);
|
sl@0
|
753 |
|
sl@0
|
754 |
TFileName sessionPath;
|
sl@0
|
755 |
TInt r=TheFs.SessionPath(sessionPath);
|
sl@0
|
756 |
test(r==KErrNone);
|
sl@0
|
757 |
r=TheFs.MkDir(_L("\\F32-TST\\"));
|
sl@0
|
758 |
test((r==KErrNone)||(r==KErrAlreadyExists));
|
sl@0
|
759 |
r=TheFs.MkDir(_L("\\F32-TST\\BENCH_DELETE\\"));
|
sl@0
|
760 |
test((r==KErrNone)||(r==KErrAlreadyExists));
|
sl@0
|
761 |
TBuf8<8> WriteData =_L8("Wibbleuy");
|
sl@0
|
762 |
for (TInt i=0;i<maxEntry;i++)
|
sl@0
|
763 |
{
|
sl@0
|
764 |
TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
|
sl@0
|
765 |
baseName.AppendNum(i);
|
sl@0
|
766 |
r=f.Replace(TheFs,baseName,EFileWrite);
|
sl@0
|
767 |
test(r==KErrNone);
|
sl@0
|
768 |
r = f.SetSize(K3GB);
|
sl@0
|
769 |
test(r==KErrNone);
|
sl@0
|
770 |
r=f.Write((K3GB-30),WriteData);
|
sl@0
|
771 |
test(r==KErrNone);
|
sl@0
|
772 |
f.Flush();
|
sl@0
|
773 |
f.Close();
|
sl@0
|
774 |
}
|
sl@0
|
775 |
|
sl@0
|
776 |
test.Printf(_L("Test all entries have been created successfully\n"));
|
sl@0
|
777 |
TBuf8<8> ReadData;
|
sl@0
|
778 |
TInt64 Size=0;
|
sl@0
|
779 |
for (TInt j=0;j<=maxEntry;j++)
|
sl@0
|
780 |
{
|
sl@0
|
781 |
TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
|
sl@0
|
782 |
baseName.AppendNum(j);
|
sl@0
|
783 |
|
sl@0
|
784 |
TInt r=f.Open(TheFs,baseName,EFileRead);
|
sl@0
|
785 |
if (r!=KErrNone)
|
sl@0
|
786 |
{
|
sl@0
|
787 |
test(r==KErrNotFound && j==maxEntry);
|
sl@0
|
788 |
return;
|
sl@0
|
789 |
}
|
sl@0
|
790 |
ReadData.FillZ();
|
sl@0
|
791 |
r=f.Read((K3GB-30),ReadData);
|
sl@0
|
792 |
test(r==KErrNone);
|
sl@0
|
793 |
test(f.Size(Size)==KErrNone);
|
sl@0
|
794 |
test(K3GB == Size);
|
sl@0
|
795 |
test(ReadData==WriteData);
|
sl@0
|
796 |
f.Close();
|
sl@0
|
797 |
}
|
sl@0
|
798 |
}
|
sl@0
|
799 |
|
sl@0
|
800 |
|
sl@0
|
801 |
LOCAL_C void TestLargeFileDelete()
|
sl@0
|
802 |
//
|
sl@0
|
803 |
// This test require MMC/SD card size >=4GB-2 in size
|
sl@0
|
804 |
//
|
sl@0
|
805 |
{
|
sl@0
|
806 |
ClearSessionDirectory();
|
sl@0
|
807 |
test.Next(_L("Benchmark delete large file"));
|
sl@0
|
808 |
|
sl@0
|
809 |
TInt64 total=0;
|
sl@0
|
810 |
|
sl@0
|
811 |
TInt cycles=1;
|
sl@0
|
812 |
|
sl@0
|
813 |
TInt i=0;
|
sl@0
|
814 |
|
sl@0
|
815 |
//check Disk space and decide how many files to create
|
sl@0
|
816 |
TVolumeInfo volInfo;
|
sl@0
|
817 |
TInt r;
|
sl@0
|
818 |
|
sl@0
|
819 |
r = TheFs.Volume(volInfo);
|
sl@0
|
820 |
test(r == KErrNone);
|
sl@0
|
821 |
|
sl@0
|
822 |
TInt numberOfFiles = (TUint)(volInfo.iFree/(K4GB -2));
|
sl@0
|
823 |
test.Printf(_L("Number of large files =%d \n"),numberOfFiles);
|
sl@0
|
824 |
|
sl@0
|
825 |
if(numberOfFiles<=0)
|
sl@0
|
826 |
{
|
sl@0
|
827 |
test.Printf(_L("Large File delete is skipped \n"));
|
sl@0
|
828 |
return;
|
sl@0
|
829 |
}
|
sl@0
|
830 |
|
sl@0
|
831 |
for (; i<cycles; i++)
|
sl@0
|
832 |
{
|
sl@0
|
833 |
// Create many files
|
sl@0
|
834 |
CreateManyLargFiles(numberOfFiles);
|
sl@0
|
835 |
|
sl@0
|
836 |
test.Next(_L("Time the delete"));
|
sl@0
|
837 |
// Now delete them and time it
|
sl@0
|
838 |
TTime startTime;
|
sl@0
|
839 |
startTime.HomeTime();
|
sl@0
|
840 |
|
sl@0
|
841 |
for (TInt index=0;index<numberOfFiles;index++)
|
sl@0
|
842 |
{
|
sl@0
|
843 |
TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
|
sl@0
|
844 |
baseName.AppendNum(index);
|
sl@0
|
845 |
|
sl@0
|
846 |
TInt r=TheFs.Delete(baseName);
|
sl@0
|
847 |
test(r==KErrNone);
|
sl@0
|
848 |
}
|
sl@0
|
849 |
|
sl@0
|
850 |
TTime endTime;
|
sl@0
|
851 |
endTime.HomeTime();
|
sl@0
|
852 |
TTimeIntervalMicroSeconds timeTaken;
|
sl@0
|
853 |
timeTaken=endTime.MicroSecondsFrom(startTime);
|
sl@0
|
854 |
TInt64 time=timeTaken.Int64();
|
sl@0
|
855 |
total+=time;
|
sl@0
|
856 |
}
|
sl@0
|
857 |
// We deleted cycles*numberOfFiles files in total microseconds
|
sl@0
|
858 |
TInt64 fileDeleteTime=total/(numberOfFiles*cycles);
|
sl@0
|
859 |
test.Next(_L("Benchmarked RFs::Delete()"));
|
sl@0
|
860 |
test.Printf(_L("Delete time per file = %d microseconds\n"),fileDeleteTime);
|
sl@0
|
861 |
|
sl@0
|
862 |
CFileMan* fMan=CFileMan::NewL(TheFs);
|
sl@0
|
863 |
total=0;
|
sl@0
|
864 |
|
sl@0
|
865 |
cycles=1;
|
sl@0
|
866 |
i=0;
|
sl@0
|
867 |
for (; i<cycles; i++)
|
sl@0
|
868 |
{
|
sl@0
|
869 |
// Create many files
|
sl@0
|
870 |
CreateManyLargFiles(numberOfFiles);
|
sl@0
|
871 |
|
sl@0
|
872 |
test.Next(_L("Time the delete"));
|
sl@0
|
873 |
// Now delete them and time it
|
sl@0
|
874 |
TTime startTime;
|
sl@0
|
875 |
startTime.HomeTime();
|
sl@0
|
876 |
|
sl@0
|
877 |
for (TInt index=0;index<numberOfFiles;index++)
|
sl@0
|
878 |
{
|
sl@0
|
879 |
TInt r=fMan->Delete(_L("\\F32-TST\\BENCH_DELETE\\FILE*"));
|
sl@0
|
880 |
test(r==KErrNone || r==KErrNotFound);
|
sl@0
|
881 |
}
|
sl@0
|
882 |
|
sl@0
|
883 |
TTime endTime;
|
sl@0
|
884 |
endTime.HomeTime();
|
sl@0
|
885 |
TTimeIntervalMicroSeconds timeTaken;
|
sl@0
|
886 |
timeTaken=endTime.MicroSecondsFrom(startTime);
|
sl@0
|
887 |
TInt64 time=timeTaken.Int64();
|
sl@0
|
888 |
total+=time;
|
sl@0
|
889 |
}
|
sl@0
|
890 |
// We deleted cycles*numberOfFiles files in total microseconds
|
sl@0
|
891 |
fileDeleteTime=total/(numberOfFiles*cycles);
|
sl@0
|
892 |
test.Next(_L("Benchmarked CFileMan::Delete()"));
|
sl@0
|
893 |
test.Printf(_L("Delete time per file = %d microseconds\n"),fileDeleteTime);
|
sl@0
|
894 |
|
sl@0
|
895 |
delete fMan;
|
sl@0
|
896 |
}
|
sl@0
|
897 |
|
sl@0
|
898 |
#endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
899 |
|
sl@0
|
900 |
|
sl@0
|
901 |
LOCAL_C void CreateManyFiles(TInt aNumber)
|
sl@0
|
902 |
//
|
sl@0
|
903 |
// Make a directory with aNumber entries
|
sl@0
|
904 |
//
|
sl@0
|
905 |
{
|
sl@0
|
906 |
RFile f;
|
sl@0
|
907 |
TInt maxEntry=aNumber;
|
sl@0
|
908 |
|
sl@0
|
909 |
test.Printf(_L("Create a directory with %d entries\n"),aNumber);
|
sl@0
|
910 |
|
sl@0
|
911 |
TFileName sessionPath;
|
sl@0
|
912 |
TInt r=TheFs.SessionPath(sessionPath);
|
sl@0
|
913 |
test(r==KErrNone);
|
sl@0
|
914 |
r=TheFs.MkDir(_L("\\F32-TST\\"));
|
sl@0
|
915 |
test((r==KErrNone)||(r==KErrAlreadyExists));
|
sl@0
|
916 |
r=TheFs.MkDir(_L("\\F32-TST\\BENCH_DELETE\\"));
|
sl@0
|
917 |
test((r==KErrNone)||(r==KErrAlreadyExists));
|
sl@0
|
918 |
|
sl@0
|
919 |
for (TInt i=0;i<maxEntry;i++)
|
sl@0
|
920 |
{
|
sl@0
|
921 |
TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
|
sl@0
|
922 |
baseName.AppendNum(i);
|
sl@0
|
923 |
r=f.Replace(TheFs,baseName,EFileRead);
|
sl@0
|
924 |
test(r==KErrNone);
|
sl@0
|
925 |
r=f.Write(_L8("Wibble"));
|
sl@0
|
926 |
test(r==KErrNone);
|
sl@0
|
927 |
f.Close();
|
sl@0
|
928 |
}
|
sl@0
|
929 |
|
sl@0
|
930 |
test.Printf(_L("Test all entries have been created successfully\n"));
|
sl@0
|
931 |
for (TInt j=0;j<=maxEntry;j++)
|
sl@0
|
932 |
{
|
sl@0
|
933 |
TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
|
sl@0
|
934 |
baseName.AppendNum(j);
|
sl@0
|
935 |
TInt r=f.Open(TheFs,baseName,EFileRead);
|
sl@0
|
936 |
if (r!=KErrNone)
|
sl@0
|
937 |
{
|
sl@0
|
938 |
test(r==KErrNotFound && j==maxEntry);
|
sl@0
|
939 |
return;
|
sl@0
|
940 |
}
|
sl@0
|
941 |
TBuf8<16> data;
|
sl@0
|
942 |
r=f.Read(data);
|
sl@0
|
943 |
test(r==KErrNone);
|
sl@0
|
944 |
test(data==_L8("Wibble"));
|
sl@0
|
945 |
f.Close();
|
sl@0
|
946 |
}
|
sl@0
|
947 |
}
|
sl@0
|
948 |
|
sl@0
|
949 |
|
sl@0
|
950 |
LOCAL_C void TestFileDelete()
|
sl@0
|
951 |
//
|
sl@0
|
952 |
//
|
sl@0
|
953 |
//
|
sl@0
|
954 |
{
|
sl@0
|
955 |
ClearSessionDirectory();
|
sl@0
|
956 |
test.Next(_L("Benchmark delete"));
|
sl@0
|
957 |
|
sl@0
|
958 |
TInt64 total=0;
|
sl@0
|
959 |
TInt numberOfFiles=100;
|
sl@0
|
960 |
TInt cycles=1;
|
sl@0
|
961 |
|
sl@0
|
962 |
TInt i=0;
|
sl@0
|
963 |
for (; i<cycles; i++)
|
sl@0
|
964 |
{
|
sl@0
|
965 |
// Create many files
|
sl@0
|
966 |
CreateManyFiles(numberOfFiles);
|
sl@0
|
967 |
|
sl@0
|
968 |
test.Next(_L("Time the delete"));
|
sl@0
|
969 |
// Now delete them and time it
|
sl@0
|
970 |
TTime startTime;
|
sl@0
|
971 |
startTime.HomeTime();
|
sl@0
|
972 |
|
sl@0
|
973 |
for (TInt index=0;index<numberOfFiles;index++)
|
sl@0
|
974 |
{
|
sl@0
|
975 |
TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
|
sl@0
|
976 |
baseName.AppendNum(index);
|
sl@0
|
977 |
|
sl@0
|
978 |
TInt r=TheFs.Delete(baseName);
|
sl@0
|
979 |
test(r==KErrNone);
|
sl@0
|
980 |
}
|
sl@0
|
981 |
|
sl@0
|
982 |
TTime endTime;
|
sl@0
|
983 |
endTime.HomeTime();
|
sl@0
|
984 |
TTimeIntervalMicroSeconds timeTaken;
|
sl@0
|
985 |
timeTaken=endTime.MicroSecondsFrom(startTime);
|
sl@0
|
986 |
TInt64 time=timeTaken.Int64();
|
sl@0
|
987 |
total+=time;
|
sl@0
|
988 |
}
|
sl@0
|
989 |
// We deleted cycles*numberOfFiles files in total microseconds
|
sl@0
|
990 |
TInt64 fileDeleteTime=total/(numberOfFiles*cycles);
|
sl@0
|
991 |
test.Next(_L("Benchmarked RFs::Delete()"));
|
sl@0
|
992 |
test.Printf(_L("Delete time per file = %d microseconds\n"),fileDeleteTime);
|
sl@0
|
993 |
|
sl@0
|
994 |
CFileMan* fMan=CFileMan::NewL(TheFs);
|
sl@0
|
995 |
total=0;
|
sl@0
|
996 |
numberOfFiles=100;
|
sl@0
|
997 |
cycles=1;
|
sl@0
|
998 |
i=0;
|
sl@0
|
999 |
for (; i<cycles; i++)
|
sl@0
|
1000 |
{
|
sl@0
|
1001 |
// Create many files
|
sl@0
|
1002 |
CreateManyFiles(numberOfFiles);
|
sl@0
|
1003 |
|
sl@0
|
1004 |
test.Next(_L("Time the delete"));
|
sl@0
|
1005 |
// Now delete them and time it
|
sl@0
|
1006 |
TTime startTime;
|
sl@0
|
1007 |
startTime.HomeTime();
|
sl@0
|
1008 |
|
sl@0
|
1009 |
for (TInt index=0;index<numberOfFiles;index++)
|
sl@0
|
1010 |
{
|
sl@0
|
1011 |
TInt r=fMan->Delete(_L("\\F32-TST\\BENCH_DELETE\\FILE*"));
|
sl@0
|
1012 |
test(r==KErrNone || r==KErrNotFound);
|
sl@0
|
1013 |
}
|
sl@0
|
1014 |
|
sl@0
|
1015 |
TTime endTime;
|
sl@0
|
1016 |
endTime.HomeTime();
|
sl@0
|
1017 |
TTimeIntervalMicroSeconds timeTaken;
|
sl@0
|
1018 |
timeTaken=endTime.MicroSecondsFrom(startTime);
|
sl@0
|
1019 |
TInt64 time=timeTaken.Int64();
|
sl@0
|
1020 |
total+=time;
|
sl@0
|
1021 |
}
|
sl@0
|
1022 |
// We deleted cycles*numberOfFiles files in total microseconds
|
sl@0
|
1023 |
fileDeleteTime=total/(numberOfFiles*cycles);
|
sl@0
|
1024 |
test.Next(_L("Benchmarked CFileMan::Delete()"));
|
sl@0
|
1025 |
test.Printf(_L("Delete time per file = %d microseconds\n"),fileDeleteTime);
|
sl@0
|
1026 |
|
sl@0
|
1027 |
delete fMan;
|
sl@0
|
1028 |
}
|
sl@0
|
1029 |
|
sl@0
|
1030 |
|
sl@0
|
1031 |
/*
|
sl@0
|
1032 |
TInt maxDirEntry=200;
|
sl@0
|
1033 |
LOCAL_C void TestDirRead()
|
sl@0
|
1034 |
//
|
sl@0
|
1035 |
// Benchmark directory read method
|
sl@0
|
1036 |
//
|
sl@0
|
1037 |
{
|
sl@0
|
1038 |
|
sl@0
|
1039 |
ClearSessionDirectory();
|
sl@0
|
1040 |
test.Next(_L("Benchmark directory read method"));
|
sl@0
|
1041 |
// Create one test entry
|
sl@0
|
1042 |
RFile f;
|
sl@0
|
1043 |
f.Create(TheFs,_L("ONE.XXX"),EFileStream);
|
sl@0
|
1044 |
f.Close();
|
sl@0
|
1045 |
TTime start;
|
sl@0
|
1046 |
start.HomeTime();
|
sl@0
|
1047 |
TInt i=0;
|
sl@0
|
1048 |
for (i=0;i<maxDirEntry;i++)
|
sl@0
|
1049 |
{
|
sl@0
|
1050 |
CDir* dirPtr;
|
sl@0
|
1051 |
TheFs.GetDir(_L("*"),KEntryAttMaskSupported,ESortByName,dirPtr);
|
sl@0
|
1052 |
delete dirPtr;
|
sl@0
|
1053 |
}
|
sl@0
|
1054 |
TTime end;
|
sl@0
|
1055 |
end.HomeTime();
|
sl@0
|
1056 |
DirReadOne=end.MicroSecondsFrom(start);
|
sl@0
|
1057 |
// Create lost of test entries
|
sl@0
|
1058 |
for (i=0;i<maxDirEntry;i++)
|
sl@0
|
1059 |
{
|
sl@0
|
1060 |
TBuf<12> baseName(_L("MANY"));
|
sl@0
|
1061 |
baseName.AppendNum(i,EHex);
|
sl@0
|
1062 |
baseName.Append(_L(".TXT"));
|
sl@0
|
1063 |
RFile f;
|
sl@0
|
1064 |
f.Create(TheFs,baseName,EFileStream);
|
sl@0
|
1065 |
f.Close();
|
sl@0
|
1066 |
}
|
sl@0
|
1067 |
start.HomeTime();
|
sl@0
|
1068 |
CDir* dirPtr;
|
sl@0
|
1069 |
TheFs.GetDir(_L("*"),KEntryAttMaskSupported,ESortByName,dirPtr);
|
sl@0
|
1070 |
delete dirPtr;
|
sl@0
|
1071 |
end.HomeTime();
|
sl@0
|
1072 |
DirReadMany=end.MicroSecondsFrom(start);
|
sl@0
|
1073 |
// Select one entry from lots
|
sl@0
|
1074 |
start.HomeTime();
|
sl@0
|
1075 |
TheFs.GetDir(_L("*.XXX"),KEntryAttMaskSupported,ESortByName,dirPtr);
|
sl@0
|
1076 |
end.HomeTime();
|
sl@0
|
1077 |
test(dirPtr->Count()==1);
|
sl@0
|
1078 |
delete dirPtr;
|
sl@0
|
1079 |
DirMatchOne=end.MicroSecondsFrom(start);
|
sl@0
|
1080 |
}
|
sl@0
|
1081 |
|
sl@0
|
1082 |
|
sl@0
|
1083 |
void LOCAL_C PrintDirResults()
|
sl@0
|
1084 |
//
|
sl@0
|
1085 |
// Print results of Directory Benchmark
|
sl@0
|
1086 |
//
|
sl@0
|
1087 |
{
|
sl@0
|
1088 |
test.Printf(_L("\nBenchmark: Dir Results\n"));
|
sl@0
|
1089 |
test.Printf(_L("Read one entry %d times = %d ms\n"),maxDirEntry,DirReadOne.Int64().GetTInt()/1000);
|
sl@0
|
1090 |
test.Printf(_L("Read %d entries = %d ms\n"),maxDirEntry,DirReadMany.Int64().GetTInt()/1000);
|
sl@0
|
1091 |
test.Printf(_L("Match 1 entry from %d entries = %d ms\n"),maxDirEntry,DirMatchOne.Int64().GetTInt()/1000);
|
sl@0
|
1092 |
test.Printf(_L("Press Enter to continue\n\n"));
|
sl@0
|
1093 |
test.Getch();
|
sl@0
|
1094 |
}
|
sl@0
|
1095 |
*/
|
sl@0
|
1096 |
|
sl@0
|
1097 |
|
sl@0
|
1098 |
LOCAL_C void TestMkDir()
|
sl@0
|
1099 |
{
|
sl@0
|
1100 |
test.Next(_L("Benchmark MkDir"));
|
sl@0
|
1101 |
ClearSessionDirectory();
|
sl@0
|
1102 |
|
sl@0
|
1103 |
TTime startTime;
|
sl@0
|
1104 |
TTime endTime;
|
sl@0
|
1105 |
TTimeIntervalMicroSeconds timeTaken(0);
|
sl@0
|
1106 |
startTime.HomeTime();
|
sl@0
|
1107 |
|
sl@0
|
1108 |
const TInt KNumDirEntries = 100;
|
sl@0
|
1109 |
for (TInt n=0; n<KNumDirEntries; n++)
|
sl@0
|
1110 |
{
|
sl@0
|
1111 |
TFileName dirName = _L("\\F32-TST\\DIR_");
|
sl@0
|
1112 |
dirName.AppendNum(n);
|
sl@0
|
1113 |
dirName.Append(_L("\\"));
|
sl@0
|
1114 |
TInt r = TheFs.MkDir(dirName);
|
sl@0
|
1115 |
test(r == KErrNone);
|
sl@0
|
1116 |
}
|
sl@0
|
1117 |
|
sl@0
|
1118 |
endTime.HomeTime();
|
sl@0
|
1119 |
timeTaken=endTime.MicroSecondsFrom(startTime);
|
sl@0
|
1120 |
TInt timeTakenInMs = I64LOW(timeTaken.Int64() / 1000);
|
sl@0
|
1121 |
test.Printf(_L("Time taken to create %d entries = %d ms\n"), KNumDirEntries, timeTakenInMs);
|
sl@0
|
1122 |
}
|
sl@0
|
1123 |
|
sl@0
|
1124 |
|
sl@0
|
1125 |
// Allocate Data Buffers for Read/Write Tests
|
sl@0
|
1126 |
void AllocateBuffers()
|
sl@0
|
1127 |
{
|
sl@0
|
1128 |
test.Printf(_L("Allocate Buffers -"));
|
sl@0
|
1129 |
|
sl@0
|
1130 |
if (gFragSharedMemory || gSharedMemory)
|
sl@0
|
1131 |
{
|
sl@0
|
1132 |
test.Printf(_L("Shared Memory\n"));
|
sl@0
|
1133 |
|
sl@0
|
1134 |
RLoader l;
|
sl@0
|
1135 |
test(l.Connect()==KErrNone);
|
sl@0
|
1136 |
test(l.CancelLazyDllUnload()==KErrNone);
|
sl@0
|
1137 |
l.Close();
|
sl@0
|
1138 |
|
sl@0
|
1139 |
test.Printf(_L("Initialise\n"));
|
sl@0
|
1140 |
TInt r = UserHal::PageSizeInBytes(PageSize);
|
sl@0
|
1141 |
test(r==KErrNone);
|
sl@0
|
1142 |
|
sl@0
|
1143 |
test.Printf(_L("Loading test driver\n"));
|
sl@0
|
1144 |
r = User::LoadLogicalDevice(KSharedChunkLddName);
|
sl@0
|
1145 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
1146 |
|
sl@0
|
1147 |
test.Printf(_L("Opening channel\n"));
|
sl@0
|
1148 |
r = Ldd.Open();
|
sl@0
|
1149 |
test(r==KErrNone);
|
sl@0
|
1150 |
|
sl@0
|
1151 |
test.Printf(_L("Create chunk\n"));
|
sl@0
|
1152 |
|
sl@0
|
1153 |
TUint aCreateFlags = EMultiple|EOwnsMemory;
|
sl@0
|
1154 |
TCommitType aCommitType = EContiguous;
|
sl@0
|
1155 |
|
sl@0
|
1156 |
TUint TotalChunkSize = ChunkSize; // rounded to nearest Page Size
|
sl@0
|
1157 |
|
sl@0
|
1158 |
TUint ChunkAttribs = TotalChunkSize|aCreateFlags;
|
sl@0
|
1159 |
r = Ldd.CreateChunk(ChunkAttribs);
|
sl@0
|
1160 |
test(r==KErrNone);
|
sl@0
|
1161 |
|
sl@0
|
1162 |
if (gSharedMemory)
|
sl@0
|
1163 |
{
|
sl@0
|
1164 |
test.Printf(_L("Commit Contigouos Memory\n"));
|
sl@0
|
1165 |
r = Ldd.CommitMemory(aCommitType,TotalChunkSize);
|
sl@0
|
1166 |
test(r==KErrNone);
|
sl@0
|
1167 |
}
|
sl@0
|
1168 |
else
|
sl@0
|
1169 |
{
|
sl@0
|
1170 |
test.Printf(_L("Commit Fragmented Memory\n"));
|
sl@0
|
1171 |
|
sl@0
|
1172 |
// Allocate Pages in reverse order to maximise memory fragmentation
|
sl@0
|
1173 |
TUint i = ChunkSize;
|
sl@0
|
1174 |
do
|
sl@0
|
1175 |
{
|
sl@0
|
1176 |
i-=PageSize;
|
sl@0
|
1177 |
test.Printf(_L("Commit %d\n"), i);
|
sl@0
|
1178 |
r = Ldd.CommitMemory(aCommitType|i,PageSize);
|
sl@0
|
1179 |
test(r==KErrNone);
|
sl@0
|
1180 |
}while (i>0);
|
sl@0
|
1181 |
/*
|
sl@0
|
1182 |
for (TInt i = (ChunkSize-PageSize); i>=0; )
|
sl@0
|
1183 |
{
|
sl@0
|
1184 |
test.Printf(_L("Commit %d\n"), i);
|
sl@0
|
1185 |
r = Ldd.CommitMemory(aCommitType|i,PageSize);
|
sl@0
|
1186 |
test(r==KErrNone);
|
sl@0
|
1187 |
i-=PageSize;
|
sl@0
|
1188 |
}
|
sl@0
|
1189 |
*/
|
sl@0
|
1190 |
}
|
sl@0
|
1191 |
|
sl@0
|
1192 |
test.Printf(_L("\nOpen user handle\n"));
|
sl@0
|
1193 |
r = Ldd.GetChunkHandle(TheChunk);
|
sl@0
|
1194 |
test(r==KErrNone);
|
sl@0
|
1195 |
|
sl@0
|
1196 |
DataBuf.Set(TheChunk.Base(),KMaxFileSize, KMaxFileSize);
|
sl@0
|
1197 |
}
|
sl@0
|
1198 |
else
|
sl@0
|
1199 |
{
|
sl@0
|
1200 |
test.Printf(_L("Heap Memory\n"));
|
sl@0
|
1201 |
DataBufH = HBufC8::New(KMaxFileSize);
|
sl@0
|
1202 |
test(DataBufH != NULL);
|
sl@0
|
1203 |
|
sl@0
|
1204 |
DataBuf.Set(DataBufH->Des());
|
sl@0
|
1205 |
}
|
sl@0
|
1206 |
}
|
sl@0
|
1207 |
|
sl@0
|
1208 |
|
sl@0
|
1209 |
void DeAllocateBuffers()
|
sl@0
|
1210 |
{
|
sl@0
|
1211 |
test.Printf(_L("DeAllocate Buffers -"));
|
sl@0
|
1212 |
|
sl@0
|
1213 |
if (gFragSharedMemory || gSharedMemory)
|
sl@0
|
1214 |
{
|
sl@0
|
1215 |
test.Printf(_L("Shared Memory\n"));
|
sl@0
|
1216 |
test.Printf(_L("Close user chunk handle\n"));
|
sl@0
|
1217 |
TheChunk.Close();
|
sl@0
|
1218 |
|
sl@0
|
1219 |
test.Printf(_L("Close kernel chunk handle\n"));
|
sl@0
|
1220 |
TInt r = Ldd.CloseChunk();
|
sl@0
|
1221 |
test(r==1);
|
sl@0
|
1222 |
|
sl@0
|
1223 |
test.Printf(_L("Check chunk is destroyed\n"));
|
sl@0
|
1224 |
r = Ldd.IsDestroyed();
|
sl@0
|
1225 |
test(r==1);
|
sl@0
|
1226 |
|
sl@0
|
1227 |
test.Printf(_L("Close test driver\n"));
|
sl@0
|
1228 |
Ldd.Close();
|
sl@0
|
1229 |
}
|
sl@0
|
1230 |
else
|
sl@0
|
1231 |
{
|
sl@0
|
1232 |
test.Printf(_L("Heap Memory\n"));
|
sl@0
|
1233 |
test.Printf(_L("Delete Heap Buffer\n"));
|
sl@0
|
1234 |
delete DataBufH;
|
sl@0
|
1235 |
}
|
sl@0
|
1236 |
}
|
sl@0
|
1237 |
|
sl@0
|
1238 |
void ParseCommandLine()
|
sl@0
|
1239 |
{
|
sl@0
|
1240 |
TBuf<0x100> cmd;
|
sl@0
|
1241 |
User::CommandLine(cmd);
|
sl@0
|
1242 |
TLex lex(cmd);
|
sl@0
|
1243 |
|
sl@0
|
1244 |
for (TPtrC token=lex.NextToken(); token.Length() != 0;token.Set(lex.NextToken()))
|
sl@0
|
1245 |
{
|
sl@0
|
1246 |
if (token.MatchF(RProcess().FileName())==0)
|
sl@0
|
1247 |
{
|
sl@0
|
1248 |
continue;
|
sl@0
|
1249 |
}
|
sl@0
|
1250 |
|
sl@0
|
1251 |
if (token.CompareF(_L("-m"))== 0)
|
sl@0
|
1252 |
{
|
sl@0
|
1253 |
gMisalignedReadWrites = ETrue;
|
sl@0
|
1254 |
continue;
|
sl@0
|
1255 |
}
|
sl@0
|
1256 |
if (token.CompareF(_L("-r"))== 0)
|
sl@0
|
1257 |
{
|
sl@0
|
1258 |
gReadCachingOn = EFalse;
|
sl@0
|
1259 |
continue;
|
sl@0
|
1260 |
}
|
sl@0
|
1261 |
if (token.CompareF(_L("+r"))== 0)
|
sl@0
|
1262 |
{
|
sl@0
|
1263 |
gReadCachingOn = ETrue;
|
sl@0
|
1264 |
continue;
|
sl@0
|
1265 |
}
|
sl@0
|
1266 |
if (token.CompareF(_L("-w"))== 0)
|
sl@0
|
1267 |
{
|
sl@0
|
1268 |
gWriteCachingOn = EFalse;
|
sl@0
|
1269 |
continue;
|
sl@0
|
1270 |
}
|
sl@0
|
1271 |
if (token.CompareF(_L("+w"))== 0)
|
sl@0
|
1272 |
{
|
sl@0
|
1273 |
gWriteCachingOn = ETrue;
|
sl@0
|
1274 |
continue;
|
sl@0
|
1275 |
}
|
sl@0
|
1276 |
|
sl@0
|
1277 |
if (token.CompareF(_L("-f"))== 0)
|
sl@0
|
1278 |
{
|
sl@0
|
1279 |
gFlushAfterWrite = EFalse;
|
sl@0
|
1280 |
continue;
|
sl@0
|
1281 |
}
|
sl@0
|
1282 |
if (token.CompareF(_L("+f"))== 0)
|
sl@0
|
1283 |
{
|
sl@0
|
1284 |
gFlushAfterWrite = ETrue;
|
sl@0
|
1285 |
continue;
|
sl@0
|
1286 |
}
|
sl@0
|
1287 |
if (token.CompareF(_L("+s"))== 0)
|
sl@0
|
1288 |
{
|
sl@0
|
1289 |
gSharedMemory = ETrue;
|
sl@0
|
1290 |
continue;
|
sl@0
|
1291 |
}
|
sl@0
|
1292 |
if (token.CompareF(_L("+x"))== 0)
|
sl@0
|
1293 |
{
|
sl@0
|
1294 |
gFragSharedMemory = ETrue;
|
sl@0
|
1295 |
continue;
|
sl@0
|
1296 |
}
|
sl@0
|
1297 |
|
sl@0
|
1298 |
test.Printf(_L("CLP=%S\n"),&token);
|
sl@0
|
1299 |
|
sl@0
|
1300 |
if(token.Length()!=0)
|
sl@0
|
1301 |
{
|
sl@0
|
1302 |
gDriveToTest=token[0];
|
sl@0
|
1303 |
gDriveToTest.UpperCase();
|
sl@0
|
1304 |
}
|
sl@0
|
1305 |
else
|
sl@0
|
1306 |
gDriveToTest='C';
|
sl@0
|
1307 |
|
sl@0
|
1308 |
#if defined SYMBIAN_TEST_COPY
|
sl@0
|
1309 |
token.Set(lex.NextToken());
|
sl@0
|
1310 |
if(token.Length()!=0)
|
sl@0
|
1311 |
{
|
sl@0
|
1312 |
gDriveToTest2=token[0];
|
sl@0
|
1313 |
gDriveToTest2.UpperCase();
|
sl@0
|
1314 |
}
|
sl@0
|
1315 |
else
|
sl@0
|
1316 |
gDriveToTest2='C';
|
sl@0
|
1317 |
test.Printf(_L("CLP2=%S\n"),&token);
|
sl@0
|
1318 |
#endif
|
sl@0
|
1319 |
|
sl@0
|
1320 |
}
|
sl@0
|
1321 |
}
|
sl@0
|
1322 |
|
sl@0
|
1323 |
|
sl@0
|
1324 |
GLDEF_C void CallTestsL(void)
|
sl@0
|
1325 |
//
|
sl@0
|
1326 |
// Call all tests
|
sl@0
|
1327 |
//
|
sl@0
|
1328 |
{
|
sl@0
|
1329 |
test.Title();
|
sl@0
|
1330 |
test.Start(_L("Start Benchmarking ..."));
|
sl@0
|
1331 |
|
sl@0
|
1332 |
test.Next(gSessionPath);
|
sl@0
|
1333 |
|
sl@0
|
1334 |
ParseCommandLine();
|
sl@0
|
1335 |
|
sl@0
|
1336 |
AllocateBuffers();
|
sl@0
|
1337 |
RProcess().SetPriority(EPriorityBackground);
|
sl@0
|
1338 |
|
sl@0
|
1339 |
TInt r = HAL::Get(HAL::EFastCounterFrequency, gFastCounterFreq);
|
sl@0
|
1340 |
test(r == KErrNone);
|
sl@0
|
1341 |
test.Printf(_L("HAL::EFastCounterFrequency %d\n"), gFastCounterFreq);
|
sl@0
|
1342 |
|
sl@0
|
1343 |
test.Printf(_L("gReadCachingOn %d gWriteCachingOn %d gFlushAfterWrite %d\n"), gReadCachingOn, gWriteCachingOn, gFlushAfterWrite);
|
sl@0
|
1344 |
|
sl@0
|
1345 |
TestFileSeek();
|
sl@0
|
1346 |
|
sl@0
|
1347 |
// read once
|
sl@0
|
1348 |
TestFileRead(KMaxFileSize, gMisalignedReadWrites, EFalse);
|
sl@0
|
1349 |
|
sl@0
|
1350 |
// re-read
|
sl@0
|
1351 |
TestFileRead(KMaxFileSize, gMisalignedReadWrites, ETrue);
|
sl@0
|
1352 |
|
sl@0
|
1353 |
TestFileReadCPU(gMisalignedReadWrites);
|
sl@0
|
1354 |
|
sl@0
|
1355 |
// append to file
|
sl@0
|
1356 |
TestFileWrite(KMaxFileSize, gMisalignedReadWrites, EFalse);
|
sl@0
|
1357 |
|
sl@0
|
1358 |
// update (overwrite) file
|
sl@0
|
1359 |
TestFileWrite(KMaxFileSize, gMisalignedReadWrites, ETrue);
|
sl@0
|
1360 |
|
sl@0
|
1361 |
TestFileWriteCPU(gMisalignedReadWrites);
|
sl@0
|
1362 |
|
sl@0
|
1363 |
TestFileDelete();
|
sl@0
|
1364 |
|
sl@0
|
1365 |
// TestDirRead();
|
sl@0
|
1366 |
// PrintDirResults();
|
sl@0
|
1367 |
#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
1368 |
TestLargeFileDelete();
|
sl@0
|
1369 |
#endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
1370 |
|
sl@0
|
1371 |
TestMkDir();
|
sl@0
|
1372 |
|
sl@0
|
1373 |
RecursiveRmDir(gSessionPath);
|
sl@0
|
1374 |
|
sl@0
|
1375 |
DeAllocateBuffers();
|
sl@0
|
1376 |
|
sl@0
|
1377 |
test.End();
|
sl@0
|
1378 |
test.Close();
|
sl@0
|
1379 |
}
|