|
1 /** |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Macros for performance testing |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file |
|
24 @internalComponent |
|
25 */ |
|
26 #include <e32def.h> |
|
27 #include <f32file.h> |
|
28 #include "EComSessionAux.h" |
|
29 |
|
30 #ifndef ECOM_PERFORMANCE_H |
|
31 #define ECOM_PERFORMANCE_H |
|
32 |
|
33 #ifdef __ECOM_SERVER_PERFORMANCE__ |
|
34 |
|
35 // Defines the sizes of the static arrays used to store fast count records. |
|
36 static const TUint KEComStartupStateTimerResultMaxCount = 20; |
|
37 static const TUint KAccumulatedClientRequestTimerResultMaxCount = 500; |
|
38 static const TUint KEComPerfTimerRecordMaxCount = 200; |
|
39 static const TUint KEComStartupStateHeapResultMaxCount=20; |
|
40 |
|
41 /** |
|
42 This class is provided for performance testability. If the testing |
|
43 compile time flag __ECOM_SERVER_PERFORMANCE__ is not defined the methods |
|
44 are not accessible. |
|
45 */ |
|
46 class EComPerformance |
|
47 { |
|
48 public: |
|
49 /** |
|
50 This method is an accessor to get the timer results stored |
|
51 during the startup of EComServer. If the requested timer value at aTimerIdx |
|
52 does not exist aTimerResult is set to 0 and aState is set to -1. |
|
53 @param aTimerIdx the index of the timer to use (a zero indexed value) |
|
54 @param aTimerResult the timer readings |
|
55 @param aState the state of the server when timer was read |
|
56 */ |
|
57 static TInt GetStartupStateTimerResult(TInt aTimerIdx, TUint32& aTimerResult, TInt& aState); |
|
58 |
|
59 /** |
|
60 This method is used to record timer values with the state that |
|
61 EComServer is in when this method is called. |
|
62 @param aState the state of the server |
|
63 */ |
|
64 static void RecordStartupStateTimerResult(TInt aState); |
|
65 |
|
66 /** |
|
67 This method is used to reset timer counter iEComStartupStateTimerResultCount |
|
68 so that the code part for recording ECom Startup State Timer Results can be reused |
|
69 for re-discover performance test. |
|
70 */ |
|
71 static void ResetStartupStateTimerResult(); |
|
72 |
|
73 /** |
|
74 This method is used to record timer values with the state that |
|
75 EComServer is in as well as the type of client request it is processing |
|
76 @param aTimerIdx the index of the time entry to get (a zero indexed value) |
|
77 @param aTimerEntry the entry returns |
|
78 */ |
|
79 static TInt GetAccumulatedClientRequestTimerResult(TInt aTimerIdx, TClientRequestTimerEntry& aTimerEntry); |
|
80 /** |
|
81 This method is used to record timer values with the state that |
|
82 EComServer is in as well as the type of client request it is processing |
|
83 @param aClientRequestType the type of the client request |
|
84 @param aState the state of the server |
|
85 */ |
|
86 static void RecordStartClientRequestTimerResult(TEComClientRequestType aClientRequestType, TInt aState); |
|
87 /** |
|
88 This method is used to end a timer values with the state that |
|
89 EComServer is in as well as the type of client request it is processing |
|
90 */ |
|
91 static void RecordEndClientRequestTimerResult(); |
|
92 |
|
93 /** |
|
94 This method is an accessor to get the fast count records stored on server side. The types of |
|
95 the records are defined by TEComPerfTimeRecordType. |
|
96 If the requested aTimeIdx exceeds the size of valid records, KErrOverflow will be returned. |
|
97 @param aTimerIdx the index of the record to get (a zero indexed value) |
|
98 @param aTimeRecord the record readings |
|
99 */ |
|
100 static TInt GetEComPerfTimeRecord(TInt aTimeIdx, TEComPerfTimeRecordEntry& aTimeRecord); |
|
101 |
|
102 /** |
|
103 This method is used to record fast count values with an additional information |
|
104 as well as the type of the record to distinguish the functions it measures |
|
105 @param aType the type of the record |
|
106 @param aInfo an additional information to be held by the record |
|
107 */ |
|
108 static void RecordEComPerfTime(TEComPerfTimeRecordType aType, TInt aInfo); |
|
109 |
|
110 /** |
|
111 This method is used to cleanup iEComPerfTimeRecords and reset counter iEComPerfTimeRecordCount |
|
112 so that the array for recording ECom performance time records can be reused. |
|
113 */ |
|
114 static void ResetEComPerfTimeRecords(); |
|
115 |
|
116 /** |
|
117 This method is used to record the commited heap size at various startup stage |
|
118 */ |
|
119 static void RecordEComHeapSize(TInt aState); |
|
120 |
|
121 /** |
|
122 This method is used to retrieve a heap entry at a specified index |
|
123 */ |
|
124 static TInt GetEComHeapSize(TInt aHeapIdx,TEComPerfHeapUsage& aHeapRecord); |
|
125 |
|
126 private: |
|
127 static TUint32 iEComStartupStateTimerResults[KEComStartupStateTimerResultMaxCount]; |
|
128 static TInt iEComStartupStateTimerResultCount; |
|
129 |
|
130 static TClientRequestTimerEntry iAccumulatedClientRequestTimerResults[KAccumulatedClientRequestTimerResultMaxCount]; |
|
131 static TInt iAccumulatedClientRequestTimerResultCount; |
|
132 |
|
133 static TEComPerfTimeRecordEntry iEComPerfTimeRecords[KEComPerfTimerRecordMaxCount]; |
|
134 static TInt iEComPerfTimeRecordCount; |
|
135 |
|
136 static TEComPerfHeapUsage iEComStartupStateHeapResults[KEComStartupStateHeapResultMaxCount]; |
|
137 static TInt iEComStartupStateHeapResultCount; |
|
138 |
|
139 // Friend class for unit tests |
|
140 friend class CDiscovererTest; |
|
141 }; |
|
142 |
|
143 #define START_TIMER EComPerformance::RecordStartupStateTimerResult(-1); |
|
144 #define RECORD_INITIALISE_RESULT EComPerformance::RecordStartupStateTimerResult(-1); |
|
145 #define START_HEAP EComPerformance::RecordEComHeapSize(-1); |
|
146 #define RECORD_INITIALISE_HEAP EComPerformance::RecordEComHeapSize(-1); |
|
147 #define RECORD_STARTUP_STATE_TIMER_RESULT(aState) EComPerformance::RecordStartupStateTimerResult(aState); |
|
148 #define RECORD_STARTUP_STATE_HEAP_RESULT(aState) EComPerformance::RecordEComHeapSize(aState); |
|
149 #define RECORD_CLIENT_REQUEST_START_TIMER_RESULT(aRequestType, aState) EComPerformance::RecordStartClientRequestTimerResult(aRequestType, aState) |
|
150 #define RECORD_CLIENT_REQUEST_END_TIMER_RESULT EComPerformance::RecordEndClientRequestTimerResult() |
|
151 |
|
152 #define RECORD_START_NOTIFIER_RUNL_TIMER_RESULT(aDriveNum) EComPerformance::RecordEComPerfTime(ECDiscovererNotifierRunL, aDriveNum); |
|
153 #define RECORD_END_NOTIFIER_RUNL_TIMER_RESULT(aDriveNum) EComPerformance::RecordEComPerfTime(ECDiscovererNotifierRunL, aDriveNum); |
|
154 #define RECORD_START_TIMER_RUNL_TIMER_RESULT EComPerformance::RecordEComPerfTime(ECDiscovererTimerRunL, -1); |
|
155 #define RECORD_END_TIMER_RUNL_TIMER_RESULT EComPerformance::RecordEComPerfTime(ECDiscovererTimerRunL, -1); |
|
156 #define RECORD_START_REDISCOVERYSCANDIRECTORY_RESULT(aDriveNum) EComPerformance::RecordEComPerfTime(ECDiscovererRediscoveryScanDirectoryL, aDriveNum); |
|
157 #define RECORD_END_REDISCOVERYSCANDIRECTORY_RESULT(aDriveNum) EComPerformance::RecordEComPerfTime(ECDiscovererRediscoveryScanDirectoryL, aDriveNum); |
|
158 #else //__ECOM_SERVER_PERFORMANCE__ |
|
159 |
|
160 #define START_TIMER |
|
161 #define RECORD_INITIALISE_RESULT |
|
162 #define START_HEAP |
|
163 #define RECORD_INITIALISE_HEAP |
|
164 #define RECORD_STARTUP_STATE_TIMER_RESULT(aState) |
|
165 #define RECORD_STARTUP_STATE_HEAP_RESULT(aState) |
|
166 #define RECORD_CLIENT_REQUEST_START_TIMER_RESULT(aRequestType, aState) |
|
167 #define RECORD_CLIENT_REQUEST_END_TIMER_RESULT |
|
168 |
|
169 #define RECORD_START_NOTIFIER_RUNL_TIMER_RESULT(aDriveNum) |
|
170 #define RECORD_END_NOTIFIER_RUNL_TIMER_RESULT(aDriveNum) |
|
171 #define RECORD_START_TIMER_RUNL_TIMER_RESULT |
|
172 #define RECORD_END_TIMER_RUNL_TIMER_RESULT |
|
173 #define RECORD_START_REDISCOVERYSCANDIRECTORY_RESULT(aDriveNum) |
|
174 #define RECORD_END_REDISCOVERYSCANDIRECTORY_RESULT(aDriveNum) |
|
175 #endif //__ECOM_SERVER_PERFORMANCE__ |
|
176 |
|
177 #endif //ECOM_PERFORMANCE_H |