diff options
Diffstat (limited to 'linden/indra/llcommon/llfasttimer.h')
-rw-r--r-- | linden/indra/llcommon/llfasttimer.h | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/linden/indra/llcommon/llfasttimer.h b/linden/indra/llcommon/llfasttimer.h new file mode 100644 index 0000000..e598096 --- /dev/null +++ b/linden/indra/llcommon/llfasttimer.h | |||
@@ -0,0 +1,206 @@ | |||
1 | /** | ||
2 | * @file llfasttimer.h | ||
3 | * @brief Declaration of a fast timer. | ||
4 | * | ||
5 | * Copyright (c) 2004-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_LLFASTTIMER_H | ||
29 | #define LL_LLFASTTIMER_H | ||
30 | |||
31 | #include "lltimer.h" | ||
32 | |||
33 | #define FAST_TIMER_ON 1 | ||
34 | |||
35 | U64 get_cpu_clock_count(); | ||
36 | |||
37 | class LLFastTimer | ||
38 | { | ||
39 | public: | ||
40 | enum EFastTimerType | ||
41 | { | ||
42 | // high level | ||
43 | FTM_FRAME, | ||
44 | FTM_UPDATE, | ||
45 | FTM_RENDER, | ||
46 | FTM_SWAP, | ||
47 | FTM_IDLE, | ||
48 | FTM_SLEEP, | ||
49 | |||
50 | // common simulate components | ||
51 | FTM_UPDATE_ANIMATION, | ||
52 | FTM_UPDATE_TERRAIN, | ||
53 | FTM_UPDATE_PRIMITIVES, | ||
54 | FTM_UPDATE_PARTICLES, | ||
55 | FTM_UPDATE_SKY, | ||
56 | FTM_UPDATE_TEXTURES, | ||
57 | |||
58 | // common render components | ||
59 | FTM_RENDER_GEOMETRY, | ||
60 | FTM_RENDER_TERRAIN, | ||
61 | FTM_RENDER_SIMPLE, | ||
62 | FTM_RENDER_SHINY, | ||
63 | FTM_RENDER_BUMP, | ||
64 | FTM_RENDER_TREES, | ||
65 | FTM_RENDER_CHARACTERS, | ||
66 | FTM_RENDER_OCCLUSION, | ||
67 | FTM_RENDER_ALPHA, | ||
68 | FTM_RENDER_CLOUDS, | ||
69 | FTM_RENDER_HUD, | ||
70 | FTM_RENDER_PARTICLES, | ||
71 | FTM_RENDER_WATER, | ||
72 | FTM_RENDER_TIMER, | ||
73 | FTM_RENDER_UI, | ||
74 | FTM_RENDER_FONTS, | ||
75 | |||
76 | // newview specific | ||
77 | FTM_MESSAGES, | ||
78 | FTM_REBUILD, | ||
79 | FTM_STATESORT, | ||
80 | FTM_POOLS, | ||
81 | FTM_POOLRENDER, | ||
82 | FTM_IDLE_CB, | ||
83 | FTM_WORLD_UPDATE, | ||
84 | FTM_UPDATE_MOVE, | ||
85 | FTM_OCTREE_BALANCE, | ||
86 | FTM_UPDATE_LIGHTS, | ||
87 | FTM_CULL, | ||
88 | FTM_CULL_REBOUND, | ||
89 | FTM_GEO_UPDATE, | ||
90 | FTM_GEO_RESERVE, | ||
91 | FTM_GEO_LIGHT, | ||
92 | FTM_GEO_SHADOW, | ||
93 | FTM_GEN_VOLUME, | ||
94 | FTM_GEN_TRIANGLES, | ||
95 | FTM_GEN_FLEX, | ||
96 | FTM_AUDIO_UPDATE, | ||
97 | FTM_RESET_DRAWORDER, | ||
98 | FTM_OBJECTLIST_UPDATE, | ||
99 | FTM_AVATAR_UPDATE, | ||
100 | FTM_JOINT_UPDATE, | ||
101 | FTM_ATTACHMENT_UPDATE, | ||
102 | FTM_LOD_UPDATE, | ||
103 | FTM_REGION_UPDATE, | ||
104 | FTM_CLEANUP, | ||
105 | FTM_NETWORK, | ||
106 | FTM_IDLE_NETWORK, | ||
107 | FTM_CREATE_OBJECT, | ||
108 | FTM_LOAD_AVATAR, | ||
109 | FTM_PROCESS_MESSAGES, | ||
110 | FTM_PROCESS_OBJECTS, | ||
111 | FTM_PROCESS_IMAGES, | ||
112 | FTM_IMAGE_UPDATE, | ||
113 | FTM_IMAGE_CREATE, | ||
114 | FTM_IMAGE_DECODE, | ||
115 | FTM_PIPELINE, | ||
116 | FTM_VFILE_WAIT, | ||
117 | FTM_FLEXIBLE_UPDATE, | ||
118 | FTM_OCCLUSION, | ||
119 | FTM_OCCLUSION_READBACK, | ||
120 | FTM_HUD_EFFECTS, | ||
121 | FTM_HUD_UPDATE, | ||
122 | FTM_INVENTORY, | ||
123 | FTM_AUTO_SELECT, | ||
124 | FTM_ARRANGE, | ||
125 | FTM_FILTER, | ||
126 | FTM_REFRESH, | ||
127 | FTM_SORT, | ||
128 | |||
129 | // Temp | ||
130 | FTM_TEMP1, | ||
131 | FTM_TEMP2, | ||
132 | FTM_TEMP3, | ||
133 | FTM_TEMP4, | ||
134 | FTM_TEMP5, | ||
135 | FTM_TEMP6, | ||
136 | FTM_TEMP7, | ||
137 | FTM_TEMP8, | ||
138 | |||
139 | FTM_OTHER, // Special, used by display code | ||
140 | |||
141 | FTM_NUM_TYPES | ||
142 | }; | ||
143 | enum { FTM_HISTORY_NUM = 60 }; | ||
144 | enum { FTM_MAX_DEPTH = 64 }; | ||
145 | |||
146 | public: | ||
147 | LLFastTimer(EFastTimerType type) | ||
148 | { | ||
149 | #if FAST_TIMER_ON | ||
150 | mType = type; | ||
151 | |||
152 | // These don't get counted, because they use CPU clockticks | ||
153 | //gTimerBins[gCurTimerBin]++; | ||
154 | //LLTimer::sNumTimerCalls++; | ||
155 | |||
156 | U64 cpu_clocks = get_cpu_clock_count(); | ||
157 | |||
158 | sStart[sCurDepth] = cpu_clocks; | ||
159 | sCurDepth++; | ||
160 | #endif | ||
161 | }; | ||
162 | ~LLFastTimer() | ||
163 | { | ||
164 | #if FAST_TIMER_ON | ||
165 | U64 end,delta; | ||
166 | int i; | ||
167 | |||
168 | // These don't get counted, because they use CPU clockticks | ||
169 | //gTimerBins[gCurTimerBin]++; | ||
170 | //LLTimer::sNumTimerCalls++; | ||
171 | end = get_cpu_clock_count(); | ||
172 | |||
173 | sCurDepth--; | ||
174 | delta = end - sStart[sCurDepth]; | ||
175 | sCounter[mType] += delta; | ||
176 | sCalls[mType]++; | ||
177 | // Subtract delta from parents | ||
178 | for (i=0; i<sCurDepth; i++) | ||
179 | sStart[i] += delta; | ||
180 | #endif | ||
181 | } | ||
182 | |||
183 | static void reset(); | ||
184 | static U64 countsPerSecond(); | ||
185 | |||
186 | public: | ||
187 | static int sCurDepth; | ||
188 | static U64 sStart[FTM_MAX_DEPTH]; | ||
189 | static U64 sCounter[FTM_NUM_TYPES]; | ||
190 | static U64 sCalls[FTM_NUM_TYPES]; | ||
191 | static U64 sCountAverage[FTM_NUM_TYPES]; | ||
192 | static U64 sCallAverage[FTM_NUM_TYPES]; | ||
193 | static U64 sCountHistory[FTM_HISTORY_NUM][FTM_NUM_TYPES]; | ||
194 | static U64 sCallHistory[FTM_HISTORY_NUM][FTM_NUM_TYPES]; | ||
195 | static S32 sCurFrameIndex; | ||
196 | static S32 sLastFrameIndex; | ||
197 | static int sPauseHistory; | ||
198 | static int sResetHistory; | ||
199 | static F64 sCPUClockFrequency; | ||
200 | |||
201 | private: | ||
202 | EFastTimerType mType; | ||
203 | }; | ||
204 | |||
205 | |||
206 | #endif // LL_LLFASTTIMER_H | ||