|
1 /* |
|
2 * Copyright (c) 2002-2004 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef ChspsTIMEMON_H |
|
21 #define ChspsTIMEMON_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32debug.h> |
|
25 #include <e32base.h> |
|
26 #include <e32std.h> |
|
27 #include <hal.h> |
|
28 #include <e32cmn.h> |
|
29 |
|
30 /** |
|
31 * ?one_line_short_description. |
|
32 * ?other_description_lines |
|
33 * |
|
34 * @lib ?library |
|
35 * @since Series ?XX ?SeriesXX_version |
|
36 */ |
|
37 class ChspsTimeMon : public CBase |
|
38 { |
|
39 public: // Constructors and destructor |
|
40 |
|
41 /** |
|
42 * Two-phased constructor. |
|
43 */ |
|
44 static ChspsTimeMon * NewL(); |
|
45 |
|
46 /** |
|
47 * Destructor. |
|
48 */ |
|
49 virtual ~ChspsTimeMon (); |
|
50 |
|
51 public: // New functions |
|
52 /** |
|
53 * ?member_description. |
|
54 * @since Series ?XX ?SeriesXX_version |
|
55 * @param ?arg1 ?description |
|
56 * @return ?description |
|
57 */ |
|
58 inline static TTime StartTiming( const TDesC& aMsg ); |
|
59 |
|
60 /** |
|
61 * ?member_description. |
|
62 * @since Series ?XX ?SeriesXX_version |
|
63 * @param ?arg1 ?description |
|
64 * @return ?description |
|
65 */ |
|
66 inline static void StopTiming( TTime aStartTime, const TDesC& aMsg ); |
|
67 |
|
68 /** |
|
69 * ?member_description. |
|
70 * @since Series ?XX ?SeriesXX_version |
|
71 * @param ?arg1 ?description |
|
72 * @return ?description |
|
73 */ |
|
74 inline static void PrintUserMem(const TDesC& aMsg); |
|
75 |
|
76 public: // Functions from base classes |
|
77 |
|
78 /** |
|
79 * From ?base_class ?member_description. |
|
80 * @since Series ?XX ?SeriesXX_version |
|
81 * @param ?arg1 ?description |
|
82 * @return ?description |
|
83 */ |
|
84 //?type ?member_function( ?type ?arg1 ); |
|
85 |
|
86 protected: // New functions |
|
87 |
|
88 /** |
|
89 * ?member_description. |
|
90 * @since Series ?XX ?SeriesXX_version |
|
91 * @param ?arg1 ?description |
|
92 * @return ?description |
|
93 */ |
|
94 //?type ?member_function( ?type ?arg1 ); |
|
95 |
|
96 protected: // Functions from base classes |
|
97 |
|
98 /** |
|
99 * From ?base_class ?member_description |
|
100 */ |
|
101 //?type ?member_function(); |
|
102 |
|
103 private: |
|
104 |
|
105 /** |
|
106 * C++ default constructor. |
|
107 */ |
|
108 ChspsTimeMon (); |
|
109 |
|
110 /** |
|
111 * By default Symbian 2nd phase constructor is private. |
|
112 */ |
|
113 void ConstructL(); |
|
114 |
|
115 // Prohibit copy constructor if not deriving from CBase. |
|
116 // ?classname( const ?classname& ); |
|
117 // Prohibit assigment operator if not deriving from CBase. |
|
118 // ?classname& operator=( const ?classname& ); |
|
119 |
|
120 public: // Data |
|
121 // ?one_line_short_description_of_data |
|
122 //?data_declaration; |
|
123 |
|
124 protected: // Data |
|
125 // ?one_line_short_description_of_data |
|
126 //?data_declaration; |
|
127 |
|
128 private: // Data |
|
129 // ?one_line_short_description_of_data |
|
130 //?data_declaration; |
|
131 // Reserved pointer for future extension |
|
132 //TAny* iReserved; |
|
133 |
|
134 public: // Friend classes |
|
135 //?friend_class_declaration; |
|
136 protected: // Friend classes |
|
137 //?friend_class_declaration; |
|
138 private: // Friend classes |
|
139 //?friend_class_declaration; |
|
140 |
|
141 }; |
|
142 |
|
143 inline TTime ChspsTimeMon::StartTiming(const TDesC& aMsg ) |
|
144 { |
|
145 TTime startTime; |
|
146 startTime.HomeTime(); |
|
147 RDebug::Print( aMsg ); |
|
148 return startTime; |
|
149 } |
|
150 |
|
151 inline void ChspsTimeMon::StopTiming( TTime aStartTime, const TDesC& aMsg ) |
|
152 { |
|
153 // calculating service time |
|
154 TTime readyTime; |
|
155 readyTime.HomeTime(); |
|
156 TTimeIntervalMicroSeconds delay = readyTime.MicroSecondsFrom( aStartTime ); |
|
157 TTime transferTime(delay.Int64()); |
|
158 TBuf<64> timeString; |
|
159 transferTime.FormatL(timeString,_L(" Time: %S%C microseconds")); |
|
160 TBuf<256> tmp; |
|
161 tmp.Append( aMsg ); |
|
162 tmp.Append( timeString ); |
|
163 RDebug::Print( tmp ); |
|
164 } |
|
165 |
|
166 inline void ChspsTimeMon::PrintUserMem(const TDesC& aMsg) |
|
167 { |
|
168 TBuf<512> buffer; |
|
169 TInt freeRAM; |
|
170 HAL::Get( HALData::EMemoryRAMFree, freeRAM ); |
|
171 RHeap heap = User::Heap(); |
|
172 heap.Open(); |
|
173 TInt _size = heap.Size(); |
|
174 TInt largest = 0; |
|
175 TInt available = heap.Available( largest ); |
|
176 heap.Close(); |
|
177 _LIT( KMemoryFormat, "FreeRAM: %d kB, User: - heap %d kB, available %d kB, largest block %d kB" ); |
|
178 buffer.Format( KMemoryFormat, ( freeRAM / 1024), (_size / 1024), |
|
179 (available / 1024), (largest / 1024 ) ); |
|
180 |
|
181 RDebug::Print( _L("ChspsTimeMon::PrintUserMem RAM:%S: %S"), &aMsg, &buffer ); |
|
182 } |
|
183 |
|
184 #endif // ChspsTIMEMON_H |
|
185 |
|
186 // End of File |