diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llframestats.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llframestats.cpp | 313 |
1 files changed, 313 insertions, 0 deletions
diff --git a/linden/indra/newview/llframestats.cpp b/linden/indra/newview/llframestats.cpp new file mode 100644 index 0000000..cd49e7d --- /dev/null +++ b/linden/indra/newview/llframestats.cpp | |||
@@ -0,0 +1,313 @@ | |||
1 | /** | ||
2 | * @file llframestats.cpp | ||
3 | * @brief LLFrameStats class implementation | ||
4 | * | ||
5 | * Copyright (c) 2001-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 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include <time.h> | ||
31 | #include "llframestats.h" | ||
32 | #include "v4color.h" | ||
33 | #include "pipeline.h" | ||
34 | #include "llviewerobjectlist.h" | ||
35 | #include "lldrawpool.h" | ||
36 | #include "lldir.h" | ||
37 | |||
38 | LLFrameStats gFrameStats; | ||
39 | |||
40 | // static | ||
41 | char *LLFrameStats::sStatLabels[NUM_STATS] = { | ||
42 | "IdleNetwork", | ||
43 | "AgentMisc", | ||
44 | "ObjectUpdate", | ||
45 | "CleanDead", | ||
46 | "UpdateEffects", | ||
47 | "ImageUpdate", | ||
48 | "UpdateMove", | ||
49 | "UpdateParticles", | ||
50 | "UpdateCull", | ||
51 | "UpdateGeom", | ||
52 | "Audio", | ||
53 | "UpdateTexStats", | ||
54 | "StateSort", | ||
55 | "Rebuild", | ||
56 | "RenderSync", | ||
57 | "RenderGeom", | ||
58 | "RenderUI", | ||
59 | "MiscEnd" | ||
60 | }; | ||
61 | |||
62 | LLColor4 LLFrameStats::sStatColors[NUM_STATS] = { | ||
63 | LLColor4(0.0f, 0.5f, 1.0f, 0.5f), // IdleNetwork | ||
64 | LLColor4(0.0f, 0.5f, 0.0f, 0.5f), // AgentMisc | ||
65 | LLColor4(0.0f, 0.0f, 1.0f, 0.5f), // ObjectUpdate | ||
66 | LLColor4(0.5f, 0.25f,0.5f, 0.5f), // CleanDead | ||
67 | LLColor4(0.5f, 0.5f, 0.5f, 0.5f), // UpdateEffects | ||
68 | LLColor4(0.5f, 1.0f, 0.0f, 0.5f), // ImageUpdate | ||
69 | LLColor4(1.0f, 1.0f, 0.0f, 0.5f), // UpdateMove | ||
70 | LLColor4(0.0f, 0.0f, 1.0f, 0.5f), // UpdateParticles | ||
71 | LLColor4(1.0f, 0.0f, 0.0f, 0.5f), // UpdateCull | ||
72 | LLColor4(0.5f, 0.0f, 0.0f, 0.5f), // UpdateGeom | ||
73 | LLColor4(0.0f, 0.5f, 0.5f, 0.5f), // Audio | ||
74 | LLColor4(0.5f, 1.0f, 1.0f, 0.5f), // UpdateTexStats | ||
75 | LLColor4(0.0f, 0.0f, 0.5f, 0.5f), // StateSort | ||
76 | LLColor4(1.0f, 0.0f, 1.0f, 0.5f), // Rebuild | ||
77 | LLColor4(0.0f, 0.5f, 1.0f, 0.5f), // RenderSync | ||
78 | LLColor4(1.0f, 1.0f, 1.0f, 0.5f), // RenderGeom | ||
79 | LLColor4(0.5f, 0.5f, 0.5f, 0.5f), // RenderUI | ||
80 | LLColor4(1.0f, 0.0f, 0.0f, 0.5f) // MiscEnd | ||
81 | }; | ||
82 | |||
83 | LLFrameStats::LLFrameStats() | ||
84 | { | ||
85 | mCurrentStat = NUM_STATS; | ||
86 | mTrackStats = FALSE; | ||
87 | mStopTime = FALSE; | ||
88 | mUseTimer = FALSE; | ||
89 | mStopTime = 0.f; | ||
90 | mFilename = "frame_stats"; | ||
91 | } | ||
92 | |||
93 | LLFrameStats::~LLFrameStats() | ||
94 | { | ||
95 | mFrameData.reset(); | ||
96 | } | ||
97 | |||
98 | void LLFrameStats::start(const EStat stat) | ||
99 | { | ||
100 | stop(); | ||
101 | mCurrentStat = stat; | ||
102 | mStats[stat].start(); | ||
103 | } | ||
104 | |||
105 | void LLFrameStats::stop() | ||
106 | { | ||
107 | if (NUM_STATS != mCurrentStat) | ||
108 | { | ||
109 | mStats[mCurrentStat].addValue(); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | extern S32 gFullObjectUpdates; | ||
114 | extern S32 gTerseObjectUpdates; | ||
115 | |||
116 | |||
117 | void LLFrameStats::addFrameData() | ||
118 | { | ||
119 | if (NUM_STATS == mCurrentStat) | ||
120 | { | ||
121 | return; | ||
122 | } | ||
123 | if (!mTrackStats) | ||
124 | { | ||
125 | return; | ||
126 | } | ||
127 | |||
128 | static FrameData frame_data; | ||
129 | |||
130 | F32 total_duration = 0.f; | ||
131 | S32 i; | ||
132 | for (i = 0; i < NUM_STATS; i++) | ||
133 | { | ||
134 | frame_data.mDuration[i] = mStats[i].getCurrentDuration(); | ||
135 | total_duration += frame_data.mDuration[i]; | ||
136 | } | ||
137 | |||
138 | frame_data.mTotalDuration = total_duration; | ||
139 | frame_data.mNumTriangles = gPipeline.mTrianglesDrawn; | ||
140 | frame_data.mNumObjects = gObjectList.getNumObjects(); | ||
141 | frame_data.mNumVisibleObjects = gPipeline.getVisibleCount(); | ||
142 | frame_data.mNumFullUpdates = gFullObjectUpdates; | ||
143 | frame_data.mNumTerseUpdates = gTerseObjectUpdates; | ||
144 | |||
145 | gFullObjectUpdates = 0; | ||
146 | gTerseObjectUpdates = 0; | ||
147 | |||
148 | |||
149 | mFrameData.put(frame_data); | ||
150 | if (mUseTimer) | ||
151 | { | ||
152 | if (mTimer.getElapsedTimeF32() > mStopTime) | ||
153 | { | ||
154 | llinfos << "Grabbed stats for " << mStopTime << " seconds, stopping and dumping" << llendl; | ||
155 | setTrackStats(FALSE); | ||
156 | } | ||
157 | } | ||
158 | } | ||
159 | |||
160 | void LLFrameStats::dump() | ||
161 | { | ||
162 | if (mFrameData.count()) | ||
163 | { | ||
164 | F32 total_time = 0; | ||
165 | S64 total_triangles = 0; | ||
166 | S32 total_frames = mFrameData.count(); | ||
167 | S32 total_num_objects = 0; | ||
168 | S32 total_visible_objects = 0; | ||
169 | |||
170 | time_t cur_time; | ||
171 | char time_str[24]; | ||
172 | //char *time_str; | ||
173 | time(&cur_time); | ||
174 | strftime(time_str, 24, "%Y.%m.%d %H:%M:%S", localtime(&cur_time)); | ||
175 | time_str[19] = '\n'; | ||
176 | time_str[20] = '\0'; | ||
177 | |||
178 | static S32 dump_count = 0; | ||
179 | |||
180 | char file_with_num[256]; | ||
181 | sprintf(file_with_num, "fs%d.txt", dump_count); | ||
182 | dump_count++; | ||
183 | |||
184 | char filename[LL_MAX_PATH]; | ||
185 | sprintf(filename, "%s", gDirUtilp->getExpandedFilename(LL_PATH_LOGS, file_with_num).c_str()); | ||
186 | FILE *fp = LLFile::fopen(filename, "w"); | ||
187 | if (!fp) | ||
188 | { | ||
189 | llinfos << "Couldn't open file for dumping frame stats!" << llendl; | ||
190 | return; | ||
191 | } | ||
192 | llinfos << "Dumping frame statistics for " << mFrameData.count() << " frames" << llendl; | ||
193 | |||
194 | fprintf(fp, "Time\tNumTriangles\t"); | ||
195 | |||
196 | S32 i; | ||
197 | for (i = 0; i < NUM_STATS; i++) | ||
198 | { | ||
199 | fprintf(fp, "%s\t", sStatLabels[i]); | ||
200 | } | ||
201 | fprintf(fp, "Full Updates\tTerse Updates\tTotal Vorbis\tLong Vorbis\tNum Vorbis Decodes\t"); | ||
202 | fprintf(fp, "\n"); | ||
203 | |||
204 | for (i = 0; i < mFrameData.count(); i++) | ||
205 | { | ||
206 | total_time += mFrameData[i].mTotalDuration; | ||
207 | total_triangles += mFrameData[i].mNumTriangles; | ||
208 | total_num_objects += mFrameData[i].mNumObjects; | ||
209 | total_visible_objects += mFrameData[i].mNumVisibleObjects; | ||
210 | |||
211 | fprintf(fp, "%f\t%d\t", mFrameData[i].mTotalDuration, mFrameData[i].mNumTriangles); | ||
212 | S32 j; | ||
213 | for (j = 0; j < NUM_STATS; j++) | ||
214 | { | ||
215 | fprintf(fp, "%f\t", mFrameData[i].mDuration[j]); | ||
216 | } | ||
217 | fprintf(fp, "%d\t", mFrameData[i].mNumFullUpdates); | ||
218 | fprintf(fp, "%d\t", mFrameData[i].mNumTerseUpdates); | ||
219 | fprintf(fp, "%f\t", mFrameData[i].mTotalVorbisTime); | ||
220 | fprintf(fp, "%f\t", mFrameData[i].mLongVorbisTime); | ||
221 | fprintf(fp, "%d\t", mFrameData[i].mNumVorbisDecodes); | ||
222 | fprintf(fp, "\n"); | ||
223 | } | ||
224 | fclose(fp); | ||
225 | |||
226 | // Now dump cumulative stats | ||
227 | sprintf(filename, "%s", gDirUtilp->getExpandedFilename(LL_PATH_LOGS, mSummaryFilename.c_str()).c_str()); | ||
228 | fp = LLFile::fopen(filename, "a"); | ||
229 | if (!fp) | ||
230 | { | ||
231 | llinfos << "Couldn't open file for dumping frame stats!" << llendl; | ||
232 | return; | ||
233 | } | ||
234 | |||
235 | fprintf(fp, "Performance data summary\n"); | ||
236 | fputs(time_str, fp); | ||
237 | |||
238 | fprintf(fp, "------------------------\n"); | ||
239 | fprintf(fp, "Total Time: %f\n", total_time); | ||
240 | fprintf(fp, "Total Frames: %d\n", total_frames); | ||
241 | fprintf(fp, "Total Triangles: %.0f\n", (F32)total_triangles); | ||
242 | fprintf(fp, "Frames/sec: %f\n", total_frames / total_time); | ||
243 | fprintf(fp, "Triangles/sec: %f\n", total_triangles/total_time); | ||
244 | fprintf(fp, "Triangles/frame: %f\n", (F32)total_triangles/(F32)total_frames); | ||
245 | fprintf(fp, "All Objects/frame: %f\n", (F32)total_num_objects/(F32)total_frames); | ||
246 | fprintf(fp, "Vis Objects/frame: %f\n", (F32)total_visible_objects/(F32)total_frames); | ||
247 | fprintf(fp, "\n"); | ||
248 | fclose(fp); | ||
249 | } | ||
250 | mFrameData.reset(); | ||
251 | } | ||
252 | |||
253 | void LLFrameStats::setTrackStats(const BOOL track_stats) | ||
254 | { | ||
255 | if (mTrackStats != track_stats) | ||
256 | { | ||
257 | if (!track_stats) | ||
258 | { | ||
259 | dump(); | ||
260 | } | ||
261 | else | ||
262 | { | ||
263 | llinfos << "Enabling stat logging" << llendl; | ||
264 | } | ||
265 | } | ||
266 | |||
267 | if (track_stats) | ||
268 | { | ||
269 | // Reset the frame data | ||
270 | mFrameData.reset(); | ||
271 | } | ||
272 | mTrackStats = track_stats; | ||
273 | } | ||
274 | |||
275 | // static callbacks | ||
276 | void LLFrameStats::startLogging(void *) | ||
277 | { | ||
278 | gFrameStats.setTrackStats(TRUE); | ||
279 | } | ||
280 | |||
281 | void LLFrameStats::stopLogging(void *) | ||
282 | { | ||
283 | gFrameStats.setTrackStats(FALSE); | ||
284 | } | ||
285 | |||
286 | void LLFrameStats::timedLogging60(void *) | ||
287 | { | ||
288 | gFrameStats.setTrackStats(TRUE); | ||
289 | gFrameStats.mTimer.reset(); | ||
290 | gFrameStats.mStopTime = 60.f; | ||
291 | gFrameStats.mUseTimer = TRUE; | ||
292 | } | ||
293 | |||
294 | void LLFrameStats::timedLogging30(void *) | ||
295 | { | ||
296 | gFrameStats.setTrackStats(TRUE); | ||
297 | gFrameStats.mTimer.reset(); | ||
298 | gFrameStats.mStopTime = 30.f; | ||
299 | gFrameStats.mUseTimer = TRUE; | ||
300 | } | ||
301 | |||
302 | void LLFrameStats::timedLogging10(void *) | ||
303 | { | ||
304 | gFrameStats.setTrackStats(TRUE); | ||
305 | gFrameStats.mTimer.reset(); | ||
306 | gFrameStats.mStopTime = 10.f; | ||
307 | gFrameStats.mUseTimer = TRUE; | ||
308 | } | ||
309 | |||
310 | const char *LLFrameStats::getCurStatName() const | ||
311 | { | ||
312 | return getStatLabel(mCurrentStat); | ||
313 | } | ||