os/kernelhwsrv/kerneltest/f32test/bench/t_fat_perf.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/**
sl@0
     2
* Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description:
sl@0
    15
* File Name:		f32test/bench/t_fat_perf.h
sl@0
    16
* Include file for t_fat_perf.cpp (PREQ 1885).
sl@0
    17
* 
sl@0
    18
*
sl@0
    19
*/
sl@0
    20
sl@0
    21
sl@0
    22
sl@0
    23
//Include Files
sl@0
    24
#include <f32file.h>
sl@0
    25
#include <e32test.h>
sl@0
    26
#include <hal.h>
sl@0
    27
#include "t_server.h"
sl@0
    28
#include "fat_utils.h"
sl@0
    29
#include "f32_test_utils.h" 
sl@0
    30
sl@0
    31
using namespace F32_Test_Utils;
sl@0
    32
using namespace Fat_Test_Utils;
sl@0
    33
sl@0
    34
extern TInt gTestCaseNo;
sl@0
    35
sl@0
    36
extern TFileName 	gPath;
sl@0
    37
extern TFileName 	gFileNameBase;
sl@0
    38
extern TInt 		gFileNo;
sl@0
    39
extern TInt		    gTestCase;
sl@0
    40
extern TInt			gCacheClear;
sl@0
    41
extern TInt         gZeroPadFileNumberForFixedLengthFileNames;
sl@0
    42
sl@0
    43
//////////////////////////////////////////////////////////////////////////////
sl@0
    44
// Interfaces
sl@0
    45
sl@0
    46
// File Operation Modes
sl@0
    47
enum TFileOperationMode
sl@0
    48
	{
sl@0
    49
	EFATPerfFileOpen,
sl@0
    50
	EFATPerfFileCreate,
sl@0
    51
	EFATPerfFileReplace,
sl@0
    52
	EFATPerfFileDelete,
sl@0
    53
	EFATPerfFileWrite,
sl@0
    54
	EFATPerfFileRead,
sl@0
    55
	};
sl@0
    56
sl@0
    57
// File Creation Options
sl@0
    58
enum TNamingConOrRan
sl@0
    59
	{
sl@0
    60
	EConsecutive,
sl@0
    61
	ERandom,
sl@0
    62
	};
sl@0
    63
sl@0
    64
// Standards
sl@0
    65
enum TNamingUniOrAsc
sl@0
    66
	{
sl@0
    67
	EAscii,
sl@0
    68
	EUnicode,
sl@0
    69
	};
sl@0
    70
sl@0
    71
// Test function names
sl@0
    72
enum TTestFunction
sl@0
    73
	{
sl@0
    74
	EFATPerfSetup,
sl@0
    75
	EFATPerfCreate,
sl@0
    76
	EFATPerfOpen,
sl@0
    77
	EFATPerfDelete,
sl@0
    78
	EFATPerfRead,
sl@0
    79
	EFATPerfWrite,
sl@0
    80
	EFATPerfDirCacheInfo,
sl@0
    81
	};
sl@0
    82
	
sl@0
    83
// For DirCache info printing 
sl@0
    84
// These enum values are based on enum TControlIO defined in \f32\sfat\common_constants.h
sl@0
    85
enum TDirCacheControlIOMap
sl@0
    86
	{
sl@0
    87
	ETestDumpFATDirCache = 15,	///<15
sl@0
    88
	ETestFATDirCacheInfo = 16,	///<16
sl@0
    89
	};
sl@0
    90
sl@0
    91
// File Naming schemes
sl@0
    92
class TNamingSchemeParam
sl@0
    93
	{
sl@0
    94
public:
sl@0
    95
    TNamingSchemeParam();
sl@0
    96
    
sl@0
    97
public:
sl@0
    98
	TNamingConOrRan	iConOrRan;
sl@0
    99
	TNamingUniOrAsc	iUniOrAsc;
sl@0
   100
	TBool iZeroPadFileNumber; // Only applies to consecutive file name generation
sl@0
   101
	TFileName 	iFileNameBase;
sl@0
   102
	TUint	iMaxFileNameLength;	// Applies only to random name generation
sl@0
   103
	TUint	iMinStringLength;
sl@0
   104
	};
sl@0
   105
sl@0
   106
class CMeasureAndLogUnit;
sl@0
   107
sl@0
   108
// File Operation Parameters
sl@0
   109
struct TFileOpUnitParam
sl@0
   110
	{
sl@0
   111
	TFileName 	iDirName;
sl@0
   112
	TNamingSchemeParam iNamingSchemeParam;
sl@0
   113
	TFileOperationMode	iFileOpMode;
sl@0
   114
	CMeasureAndLogUnit* iMLUnitPtr;
sl@0
   115
	};
sl@0
   116
sl@0
   117
// Directory Unit Parameters
sl@0
   118
struct TDirUnitParam
sl@0
   119
	{
sl@0
   120
	TUint		iPriority;
sl@0
   121
	TFileName	iDirName;
sl@0
   122
	TUint		iRuns;
sl@0
   123
	TUint		iFilesPerRun;
sl@0
   124
	TUint		iSampleInterval;
sl@0
   125
	TNamingSchemeParam		iNamingScheme;
sl@0
   126
	TFileOperationMode		iFileOpMode;
sl@0
   127
	};
sl@0
   128
sl@0
   129
struct	TMLUnitParam
sl@0
   130
	{
sl@0
   131
	TInt	iID;
sl@0
   132
	};
sl@0
   133
sl@0
   134
struct TMLParam
sl@0
   135
	{
sl@0
   136
	TFileName	iDirName;
sl@0
   137
	TFileName	iFileName;
sl@0
   138
	TNamingSchemeParam iNamingScheme;
sl@0
   139
	TUint	iCurFileNo;
sl@0
   140
	TFileOperationMode	iFileOpMode;
sl@0
   141
	};
sl@0
   142
sl@0
   143
/////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   144
// Module definition
sl@0
   145
sl@0
   146
sl@0
   147
// Measurement and Log Unit
sl@0
   148
class CMeasureAndLogUnit : CBase
sl@0
   149
	{
sl@0
   150
public:
sl@0
   151
	static CMeasureAndLogUnit* NewLC(const TMLUnitParam& aParam);
sl@0
   152
	static CMeasureAndLogUnit* NewL(const TMLUnitParam& aParam);
sl@0
   153
	~CMeasureAndLogUnit();
sl@0
   154
	TInt	MeasureStart();
sl@0
   155
	TInt	MeasureEnd();
sl@0
   156
	TInt	Log(const TFileName& aDirName, const TFileName& aFileName, TUint aCurrentFileNo, TUint aCurrentFilePos);
sl@0
   157
private:
sl@0
   158
	CMeasureAndLogUnit();
sl@0
   159
	void ConstructL(const TMLUnitParam& aParam);
sl@0
   160
	TInt	DoMeasureStart();
sl@0
   161
	TInt	DoMeasureEnd();
sl@0
   162
	TInt	DoLog(const TFileName& aFileName, TUint aCurrentFileNo, TUint aCurrentFilePos);
sl@0
   163
	
sl@0
   164
private:
sl@0
   165
	TInt	iID;
sl@0
   166
	TUint32	iStartStatus;
sl@0
   167
	TUint32	iEndStatus;
sl@0
   168
	TInt	iFreq;
sl@0
   169
	TReal	iScale;		
sl@0
   170
	TUint	iLogItemNo;
sl@0
   171
	};
sl@0
   172
sl@0
   173
// File Operation Unit
sl@0
   174
class CFileOperationUnit : CBase
sl@0
   175
	{
sl@0
   176
public:
sl@0
   177
	static CFileOperationUnit* NewLC(const TFileOpUnitParam& aParam);
sl@0
   178
	static CFileOperationUnit* NewL(const TFileOpUnitParam& aParam);
sl@0
   179
	~CFileOperationUnit();
sl@0
   180
	
sl@0
   181
	TInt 	Run(const TFileName& aDirName, const TFileName& aFileName, TBool aIsTakingMeasurement, TUint aCurFileNo, TUint aCurFilePos);
sl@0
   182
	void	SetMLUnit(CMeasureAndLogUnit* aMLUnit);
sl@0
   183
sl@0
   184
private:
sl@0
   185
	CFileOperationUnit();	
sl@0
   186
	void ConstructL(const TFileOpUnitParam& aParam);
sl@0
   187
sl@0
   188
private:
sl@0
   189
	TFileName 	iDirName;
sl@0
   190
	TNamingSchemeParam iNamingSchemeParam;
sl@0
   191
	TFileOperationMode	iFileOpMode;
sl@0
   192
	CMeasureAndLogUnit* iMLUnitPtr;
sl@0
   193
	RFs					iRFs;
sl@0
   194
	TBool				iDirCreated;
sl@0
   195
	};
sl@0
   196
sl@0
   197
sl@0
   198
class CDirUnit : public CBase
sl@0
   199
	{
sl@0
   200
public:
sl@0
   201
	static CDirUnit* NewLC(const TDirUnitParam& aParam, const TChar aDriveChar);
sl@0
   202
	static CDirUnit* NewL(const TDirUnitParam& aParam, const TChar aDriveChar);
sl@0
   203
	~CDirUnit();
sl@0
   204
	TInt Run(const TInt aCurPriority);
sl@0
   205
	void SetMLUnit(CMeasureAndLogUnit* aMLUnit);
sl@0
   206
	TInt Priority();
sl@0
   207
	const TFileName& Name();
sl@0
   208
sl@0
   209
private:
sl@0
   210
	CDirUnit();
sl@0
   211
	void ConstructL(const TDirUnitParam& aParam, const TChar aDriveChar);
sl@0
   212
sl@0
   213
	TInt 	GenerateFileName(TFileName& aFileName); // uses iNameGen
sl@0
   214
	TBool 	CheckMeasurementTaking();		     	// uses currentFileNo, 
sl@0
   215
												    // totalFileNo, 
sl@0
   216
												    // samplingInterval
sl@0
   217
	TInt 	DoFileOperation();
sl@0
   218
	TFileName GenerateRandomString(const TUint aMinStringLength, const TUint aMaxStringLength, const TNamingUniOrAsc aUniOrAsc);
sl@0
   219
	TBool FileNameIsUnique(const TFileName& aFileName);
sl@0
   220
private:
sl@0
   221
	TInt					iPriority;
sl@0
   222
	TFileName				iDirName;
sl@0
   223
	TUint					iRuns;
sl@0
   224
	TUint					iCurrentRunNo;
sl@0
   225
	TUint					iFilesPerRun;
sl@0
   226
	TUint					iCurrentFileNo;
sl@0
   227
	TUint					iTotalFileNo;
sl@0
   228
	TUint					iSampleInterval;
sl@0
   229
	
sl@0
   230
	TUint                   iNumDigitsInTotalFileNo;    // The number of digits iTotalFileNo has.
sl@0
   231
                                                        // Used to zero pad the file number if iZeroPadFileNumberForFixedWidthFileNames is ETrue
sl@0
   232
	
sl@0
   233
	TNamingConOrRan	iConOrRan;                 // Consecutive or random
sl@0
   234
	TNamingUniOrAsc	iUniOrAsc;                 // ASCII or Unicode
sl@0
   235
	TBool iZeroPadFileNumberForFixedLengthFileNames;
sl@0
   236
	TFileName 			iFileNameBase;
sl@0
   237
	TUint				iMaxFileNameLength;   // Applies only to random name generation
sl@0
   238
	TUint				iMinStringLength;     // Applies only to random name generation
sl@0
   239
	
sl@0
   240
	CFileOperationUnit* 	iFileOpUnit;
sl@0
   241
	CMeasureAndLogUnit*	iMLUnitPtr;
sl@0
   242
	
sl@0
   243
	};
sl@0
   244
sl@0
   245
//Execution Unit
sl@0
   246
class CExecutionUnit : public CBase
sl@0
   247
	{
sl@0
   248
public:
sl@0
   249
	static CExecutionUnit* NewLC(CMeasureAndLogUnit* aMLUnit, const TChar aDriveChar);
sl@0
   250
	static CExecutionUnit* NewL(CMeasureAndLogUnit* aMLUnit, const TChar aDriveChar);
sl@0
   251
sl@0
   252
	~CExecutionUnit();
sl@0
   253
sl@0
   254
	TInt 	AddDirUnitL(const TDirUnitParam& aParam);
sl@0
   255
	TInt	RecalculateCurrentPrioirty();
sl@0
   256
	TInt 	Run();
sl@0
   257
sl@0
   258
	///For Debug
sl@0
   259
	TUint ForDebug_AddrOfDirUnit(TUint aDirUnitIter);
sl@0
   260
	TUint ForDebug_AddrOfDirUnitArray();
sl@0
   261
sl@0
   262
private:
sl@0
   263
	CExecutionUnit();
sl@0
   264
	void ConstructL(CMeasureAndLogUnit* aMLUnit, const TChar aDriveChar);
sl@0
   265
sl@0
   266
private:
sl@0
   267
	// Array of CDirUnit
sl@0
   268
	RPointerArray<CDirUnit>	iDirUnitArray;
sl@0
   269
	
sl@0
   270
	// Logging Unit
sl@0
   271
	CMeasureAndLogUnit*	iMLUnitPtr;	// no ownership
sl@0
   272
	
sl@0
   273
	// Current priority
sl@0
   274
	TInt 	iCurPriority;
sl@0
   275
	
sl@0
   276
	TChar	iDriveChar;
sl@0
   277
	
sl@0
   278
	}; 
sl@0
   279
	
sl@0
   280
/*-- EOF--*/
sl@0
   281
	
sl@0
   282