1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/centralrepository/cenrepsrv/srvPerf.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,125 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef SRVPERF_H
1.20 +#define SRVPERF_H
1.21 +
1.22 +#include <e32base.h>
1.23 +
1.24 +#ifdef __CENTREP_SERVER_PERFTEST__
1.25 +#include "srvreqs.h"
1.26 +#include "clientrequest.h"
1.27 +
1.28 +enum TPseudoRequest
1.29 + {
1.30 + EEvict = EGetSetParameters+1
1.31 + };
1.32 +
1.33 +const TInt KEventIdShiftBits = 24;
1.34 +const TUint32 KEventIdMask = 0xFF;
1.35 +const TUint32 KDataMask = 0x00FFFFFF;
1.36 +
1.37 +// Only record CPU used by CentRep server.
1.38 +const TUint32 KCentRepPerfTestArraySize = 3600;
1.39 +
1.40 +class CServerSubSession;
1.41 +
1.42 +// class TCentRepPerfTest manages the performance data
1.43 +// collected by CentRep server.
1.44 +class TCentRepPerfTest
1.45 + {
1.46 +public:
1.47 + inline void SessionOpen()
1.48 + { iActiveSessionCount++; }
1.49 + inline TBool IsFinished() const // Special assumed end-of-boot condition
1.50 + { return (iCount >= KCentRepPerfTestArraySize)||(iEndOfBootCount==9); }
1.51 + inline TUint LastCompleteAccess() const
1.52 + { return iLastCompleteAccess; }
1.53 + inline const TUint32* Entries() const
1.54 + { return iEntries; }
1.55 + inline void IncEndOfBoot()
1.56 + { iEndOfBootCount++; }
1.57 + inline void Reset()
1.58 + {
1.59 + iActiveSessionCount = 0;
1.60 + iLastCompleteAccess = 0;
1.61 + iEndOfBootCount = 0;
1.62 + iCount = 0;
1.63 + }
1.64 + inline void Stop()
1.65 + {
1.66 + iCount = KCentRepPerfTestArraySize;
1.67 + }
1.68 + inline void SetCurrentRepositoryUid(TUint32 aCurrentRepositoryUid)
1.69 + { iCurrentRepositoryUid = aCurrentRepositoryUid; }
1.70 + inline TUint32 CurrentRepositoryUid()
1.71 + { return iCurrentRepositoryUid; }
1.72 +
1.73 + void SessionClose();
1.74 + TInt Append(TUint32 aEntry);
1.75 +
1.76 + //called at the beginning of a server event being executed
1.77 + void DoEventStart(CServerSubSession* aSubSession, const TClientRequest& aMessage);
1.78 +
1.79 + //called at the end of a server event being executed
1.80 + void DoEventEnd(CServerSubSession* aSubSession, const TClientRequest& aMessage);
1.81 +
1.82 + //called at the beginning of a server Initialisation
1.83 + void DoServerStart();
1.84 +
1.85 + //called at the end of a server initialisation
1.86 + void DoServerEnd();
1.87 +
1.88 +private:
1.89 + TUint32 iEntries[KCentRepPerfTestArraySize];
1.90 + TUint iCount;
1.91 + TUint iActiveSessionCount;
1.92 + TUint iLastCompleteAccess;
1.93 + TUint iEndOfBootCount;
1.94 + TUint32 iCurrentRepositoryUid;
1.95 + TUint32 iStartTick;
1.96 + };
1.97 +
1.98 + #define PERF_TEST_EVENT_START(aSubSession, aMessage) TServerResources::iPerfTestMgr.DoEventStart(aSubSession, aMessage)
1.99 + #define PERF_TEST_EVENT_END(aSubSession, aMessage) TServerResources::iPerfTestMgr.DoEventEnd(aSubSession, aMessage)
1.100 + #define PERF_TEST_SERVER_START() TServerResources::iPerfTestMgr.DoServerStart()
1.101 + #define PERF_TEST_SERVER_END() TServerResources::iPerfTestMgr.DoServerEnd()
1.102 +#else
1.103 +
1.104 + #define PERF_TEST_EVENT_START(aSubSession, aMessage)
1.105 + #define PERF_TEST_EVENT_END(aSubSession, aMessage)
1.106 + #define PERF_TEST_SERVER_START()
1.107 + #define PERF_TEST_SERVER_END()
1.108 +
1.109 +#endif //__CENTREP_SERVER_PERFTEST__
1.110 +
1.111 +#ifdef __CENTREP_SERVER_MEMTEST__
1.112 + enum TMemTestLocationIdentifier
1.113 + {
1.114 + EMemLcnRepositoryOpen, //used to measure heap usage for a repository when
1.115 + //called from CServerRepository::OpenL
1.116 + EMemLcnOnDemand //used to measure heap usage of Centrep server at any
1.117 + //time on demand. called from CServerSession::GetSetParameters
1.118 + };
1.119 + const TInt32 KMemBufMaxEntry = 150; //make sure to allocate for 2 more than required.
1.120 + //The additional 2 are used to mark when server
1.121 + //tries to save more entries then max allowed
1.122 + const TUint32 KMagicMemTestOutOfBounds = 0xDEADBEEF;
1.123 + #define RECORD_HEAP_SIZE(aLocation, aIdentifier) TServerResources::RecordTimerResult(aLocation, aIdentifier)
1.124 +#else //__CENTREP_SERVER_MEMTEST__
1.125 + #define RECORD_HEAP_SIZE(aLocation, aIdentifier)
1.126 +#endif //__CENTREP_SERVER_MEMTEST__
1.127 +
1.128 +#endif //SRVPERF_H