os/ossrv/lowlevellibsandfws/pluginfw/Framework/frame/EComPerformance.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2005-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 "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
// Implementation of static class to log ECom performance
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
/**
sl@0
    19
 @internalComponent
sl@0
    20
 @file
sl@0
    21
*/
sl@0
    22
sl@0
    23
#include <e32debug.h>
sl@0
    24
#include "EComPerformance.h"
sl@0
    25
sl@0
    26
#ifdef __ECOM_SERVER_PERFORMANCE__
sl@0
    27
sl@0
    28
TUint32 EComPerformance::iEComStartupStateTimerResults[KEComStartupStateTimerResultMaxCount];
sl@0
    29
TInt EComPerformance::iEComStartupStateTimerResultCount = 0;
sl@0
    30
TClientRequestTimerEntry EComPerformance::iAccumulatedClientRequestTimerResults[KAccumulatedClientRequestTimerResultMaxCount];
sl@0
    31
TInt EComPerformance::iAccumulatedClientRequestTimerResultCount = 0;
sl@0
    32
TEComPerfTimeRecordEntry EComPerformance::iEComPerfTimeRecords[KEComPerfTimerRecordMaxCount];
sl@0
    33
TInt EComPerformance::iEComPerfTimeRecordCount = 0;
sl@0
    34
TEComPerfHeapUsage EComPerformance::iEComStartupStateHeapResults[KEComStartupStateHeapResultMaxCount];
sl@0
    35
TInt EComPerformance::iEComStartupStateHeapResultCount=0;
sl@0
    36
sl@0
    37
/**
sl@0
    38
 Retrieves startup state timing data from the given index
sl@0
    39
 @param aTimerIdx The index of the timing entry to retrieve	
sl@0
    40
 @param aTimerResult On return contains the timing (using FastCounter) at the given index
sl@0
    41
 @param aState The state the timing data is for
sl@0
    42
 */
sl@0
    43
TInt EComPerformance::GetStartupStateTimerResult(TInt aTimerIdx, TUint32& aTimerResult, TInt& aState)
sl@0
    44
	{
sl@0
    45
	TInt resultIdx = aTimerIdx * 2;
sl@0
    46
	aTimerResult = 0;
sl@0
    47
	aState = -1;
sl@0
    48
	
sl@0
    49
	if(iEComStartupStateTimerResultCount > resultIdx + 1)
sl@0
    50
		{
sl@0
    51
		aTimerResult = iEComStartupStateTimerResults[resultIdx];
sl@0
    52
		aState = iEComStartupStateTimerResults[resultIdx+1];
sl@0
    53
		}
sl@0
    54
	else
sl@0
    55
		{
sl@0
    56
		RDebug::Print(_L("Exceeded size of %d held by KEComStartupStateTimerResults array\n"), iEComStartupStateTimerResultCount);
sl@0
    57
		return KErrOverflow;
sl@0
    58
		}
sl@0
    59
	return KErrNone;
sl@0
    60
	}
sl@0
    61
sl@0
    62
/**
sl@0
    63
 Records timing data for the given state that can be retrieved using GetStartupStateTimerResult
sl@0
    64
 @param aState The state the timing data is for
sl@0
    65
 */
sl@0
    66
void EComPerformance::RecordStartupStateTimerResult(TInt aState)
sl@0
    67
	{
sl@0
    68
	if(iEComStartupStateTimerResultCount+1<KEComStartupStateTimerResultMaxCount)
sl@0
    69
		{
sl@0
    70
		iEComStartupStateTimerResults[iEComStartupStateTimerResultCount++] = User::FastCounter();
sl@0
    71
		iEComStartupStateTimerResults[iEComStartupStateTimerResultCount++] = aState;
sl@0
    72
		}
sl@0
    73
	}
sl@0
    74
	
sl@0
    75
void EComPerformance::ResetStartupStateTimerResult()
sl@0
    76
	{
sl@0
    77
	iEComStartupStateTimerResultCount = 0;
sl@0
    78
	}
sl@0
    79
/**
sl@0
    80
 Retrieves timing data for the client request indexed by aTimerIdx
sl@0
    81
 Note that this data does not include timing for requests where an exception occurred during processing
sl@0
    82
 @param aTimerIdx The index of the timing entry to retrieve	
sl@0
    83
 @param aTimerEntry On return contains the timing data for the given index
sl@0
    84
 @return KErrNone if the timing data was retrieved successfully, KErrOverflow if the requested index is greater than the number of timing entries	
sl@0
    85
*/
sl@0
    86
TInt EComPerformance::GetAccumulatedClientRequestTimerResult(TInt aTimerIdx, TClientRequestTimerEntry& aTimerEntry)
sl@0
    87
	{
sl@0
    88
	if(aTimerIdx < iAccumulatedClientRequestTimerResultCount)
sl@0
    89
		{
sl@0
    90
		aTimerEntry = iAccumulatedClientRequestTimerResults[aTimerIdx];
sl@0
    91
		}
sl@0
    92
	else
sl@0
    93
		{
sl@0
    94
		return KErrOverflow;
sl@0
    95
		}
sl@0
    96
	return KErrNone;
sl@0
    97
	}
sl@0
    98
sl@0
    99
/**
sl@0
   100
 Records timing data for the start of the processing of a client request.
sl@0
   101
 @param aClientRequestType The type of client request
sl@0
   102
 @param aState The current start-up state
sl@0
   103
*/
sl@0
   104
void EComPerformance::RecordStartClientRequestTimerResult(TEComClientRequestType aClientRequestType, TInt aState)
sl@0
   105
	{
sl@0
   106
	if(iAccumulatedClientRequestTimerResultCount < KAccumulatedClientRequestTimerResultMaxCount)
sl@0
   107
		{
sl@0
   108
		iAccumulatedClientRequestTimerResults[iAccumulatedClientRequestTimerResultCount].iStartTime = User::FastCounter();
sl@0
   109
		iAccumulatedClientRequestTimerResults[iAccumulatedClientRequestTimerResultCount].iClientRequestType = aClientRequestType;
sl@0
   110
		iAccumulatedClientRequestTimerResults[iAccumulatedClientRequestTimerResultCount].iState = aState;
sl@0
   111
		}
sl@0
   112
	}
sl@0
   113
	
sl@0
   114
/**
sl@0
   115
 Records timing data for the end of the processing of the client request associated with the last call to RecordStartClientRequestTimerResult
sl@0
   116
 @pre RecordStartClientRequestTimerResult must have been called before this method is called
sl@0
   117
*/
sl@0
   118
void EComPerformance::RecordEndClientRequestTimerResult()
sl@0
   119
	{
sl@0
   120
	if (iAccumulatedClientRequestTimerResultCount < KAccumulatedClientRequestTimerResultMaxCount)
sl@0
   121
		{
sl@0
   122
		iAccumulatedClientRequestTimerResults[iAccumulatedClientRequestTimerResultCount].iEndTime = User::FastCounter();
sl@0
   123
		iAccumulatedClientRequestTimerResultCount++;
sl@0
   124
		}
sl@0
   125
	}
sl@0
   126
sl@0
   127
/**
sl@0
   128
 Retrieves ECom performance timing record by aTimeIdx
sl@0
   129
@param aTimerIdx the index of the record to get (a zero indexed value)
sl@0
   130
@param aTimeRecord the record readings
sl@0
   131
*/
sl@0
   132
TInt EComPerformance::GetEComPerfTimeRecord(TInt aTimeIdx, TEComPerfTimeRecordEntry& aTimeEntry)
sl@0
   133
	{
sl@0
   134
	if(aTimeIdx < KEComPerfTimerRecordMaxCount)
sl@0
   135
		{
sl@0
   136
		aTimeEntry = iEComPerfTimeRecords[aTimeIdx];
sl@0
   137
		}
sl@0
   138
	else
sl@0
   139
		{
sl@0
   140
		return KErrOverflow;		
sl@0
   141
		}
sl@0
   142
	return KErrNone;
sl@0
   143
	}
sl@0
   144
sl@0
   145
/**
sl@0
   146
 Records ECom performance timing record with its type an additional information
sl@0
   147
 @param aType The type of the record
sl@0
   148
 @param aInfo The additional inforamtion attached
sl@0
   149
*/
sl@0
   150
void EComPerformance::RecordEComPerfTime(TEComPerfTimeRecordType aType, TInt aInfo)
sl@0
   151
	{
sl@0
   152
	if(iEComPerfTimeRecordCount < KEComPerfTimerRecordMaxCount)
sl@0
   153
		{
sl@0
   154
		iEComPerfTimeRecords[iEComPerfTimeRecordCount].iTime = User::FastCounter();
sl@0
   155
		iEComPerfTimeRecords[iEComPerfTimeRecordCount].iType = aType;
sl@0
   156
		iEComPerfTimeRecords[iEComPerfTimeRecordCount].iInfo = aInfo;
sl@0
   157
		++iEComPerfTimeRecordCount;
sl@0
   158
		}
sl@0
   159
	}
sl@0
   160
sl@0
   161
/**
sl@0
   162
 Cleans up ECom performance timing record array and reset counter
sl@0
   163
*/
sl@0
   164
void EComPerformance::ResetEComPerfTimeRecords()
sl@0
   165
	{
sl@0
   166
	for(TInt idx = 0; idx <= iEComPerfTimeRecordCount; ++idx)
sl@0
   167
		{
sl@0
   168
		iEComPerfTimeRecords[idx].iTime = NULL;
sl@0
   169
		iEComPerfTimeRecords[idx].iType = ENullType;
sl@0
   170
		iEComPerfTimeRecords[idx].iInfo = NULL;
sl@0
   171
		}
sl@0
   172
	iEComPerfTimeRecordCount = 0;
sl@0
   173
	}
sl@0
   174
sl@0
   175
/**
sl@0
   176
Get the heap size at this startup state
sl@0
   177
*/	
sl@0
   178
void EComPerformance::RecordEComHeapSize(TInt aState)
sl@0
   179
	{
sl@0
   180
	if (iEComStartupStateHeapResultCount < KEComStartupStateHeapResultMaxCount)
sl@0
   181
		{
sl@0
   182
		iEComStartupStateHeapResults[iEComStartupStateHeapResultCount].iState=aState;
sl@0
   183
		iEComStartupStateHeapResults[iEComStartupStateHeapResultCount].iHeapSize=User::Heap().Size();
sl@0
   184
		++iEComStartupStateHeapResultCount;		
sl@0
   185
		}
sl@0
   186
	}
sl@0
   187
	
sl@0
   188
TInt EComPerformance::GetEComHeapSize(TInt aHeapIdx,TEComPerfHeapUsage& aHeapRecord)
sl@0
   189
	{
sl@0
   190
	if (aHeapIdx < KEComStartupStateHeapResultMaxCount)
sl@0
   191
		{
sl@0
   192
		aHeapRecord=iEComStartupStateHeapResults[aHeapIdx];
sl@0
   193
		}
sl@0
   194
	else
sl@0
   195
		{
sl@0
   196
		return KErrOverflow;
sl@0
   197
		}
sl@0
   198
	return KErrNone;
sl@0
   199
	}
sl@0
   200
sl@0
   201
#endif //__ECOM_SERVER_PERFORMANCE__