llfasttimer.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLFASTTIMER_H
00033 #define LL_LLFASTTIMER_H
00034 
00035 #define FAST_TIMER_ON 1
00036 
00037 U64 get_cpu_clock_count();
00038 
00039 class LLFastTimer
00040 {
00041 public:
00042         enum EFastTimerType
00043         {
00044                 // high level
00045                 FTM_FRAME,
00046                 FTM_UPDATE,
00047                 FTM_RENDER,
00048                 FTM_SWAP,
00049                 FTM_CLIENT_COPY,
00050                 FTM_IDLE,
00051                 FTM_SLEEP,
00052 
00053                 // common messaging components
00054                 FTM_PUMP,
00055                 FTM_CURL,
00056                 
00057                 // common simulation components
00058                 FTM_UPDATE_ANIMATION,
00059                 FTM_UPDATE_TERRAIN,
00060                 FTM_UPDATE_PRIMITIVES,
00061                 FTM_UPDATE_PARTICLES,
00062                 FTM_SIMULATE_PARTICLES,
00063                 FTM_UPDATE_SKY,
00064                 FTM_UPDATE_TEXTURES,
00065                 FTM_UPDATE_WATER,
00066                 FTM_UPDATE_CLOUDS,
00067                 FTM_UPDATE_GRASS,
00068                 FTM_UPDATE_TREE,
00069                 FTM_UPDATE_AVATAR,
00070                 
00071                 // common render components
00072                 FTM_RENDER_GEOMETRY,
00073                  FTM_RENDER_TERRAIN,
00074                  FTM_RENDER_SIMPLE,
00075                  FTM_RENDER_FULLBRIGHT,
00076                  FTM_RENDER_GLOW,
00077                  FTM_RENDER_GRASS,
00078                  FTM_RENDER_INVISIBLE,
00079                  FTM_RENDER_SHINY,
00080                  FTM_RENDER_BUMP,
00081                  FTM_RENDER_TREES,
00082                  FTM_RENDER_CHARACTERS,
00083                  FTM_RENDER_OCCLUSION,
00084                  FTM_RENDER_ALPHA,
00085          FTM_RENDER_CLOUDS,
00086                  FTM_RENDER_HUD,
00087                  FTM_RENDER_PARTICLES,
00088                  FTM_RENDER_WATER,
00089                 FTM_RENDER_TIMER,
00090                 FTM_RENDER_UI,
00091                 FTM_RENDER_FONTS,
00092                 
00093                 // newview specific
00094                 FTM_MESSAGES,
00095                 FTM_REBUILD,
00096                 FTM_STATESORT,
00097                 FTM_STATESORT_DRAWABLE,
00098                 FTM_STATESORT_POSTSORT,
00099                 FTM_REBUILD_VBO,
00100                 FTM_REBUILD_VOLUME_VB,
00101                 FTM_REBUILD_BRIDGE_VB,
00102                 FTM_REBUILD_HUD_VB,
00103                 FTM_REBUILD_TERRAIN_VB,
00104                 FTM_REBUILD_WATER_VB,
00105                 FTM_REBUILD_TREE_VB,
00106                 FTM_REBUILD_PARTICLE_VB,
00107                 FTM_REBUILD_CLOUD_VB,
00108                 FTM_REBUILD_GRASS_VB,
00109                 FTM_REBUILD_NONE_VB,
00110                 FTM_REBUILD_OCCLUSION_VB,
00111                 FTM_POOLS,
00112                 FTM_POOLRENDER,
00113                 FTM_IDLE_CB,
00114                 FTM_WORLD_UPDATE,
00115                 FTM_UPDATE_MOVE,
00116                 FTM_OCTREE_BALANCE,
00117                 FTM_UPDATE_LIGHTS,
00118                 FTM_CULL,
00119                 FTM_CULL_REBOUND,
00120                 FTM_FRUSTUM_CULL,
00121                 FTM_GEO_UPDATE,
00122                 FTM_GEO_RESERVE,
00123                 FTM_GEO_LIGHT,
00124                 FTM_GEO_SHADOW,
00125                 FTM_GEN_VOLUME,
00126                 FTM_GEN_TRIANGLES,
00127                 FTM_GEN_FLEX,
00128                 FTM_AUDIO_UPDATE,
00129                 FTM_RESET_DRAWORDER,
00130                 FTM_OBJECTLIST_UPDATE,
00131                 FTM_AVATAR_UPDATE,
00132                 FTM_JOINT_UPDATE,
00133                 FTM_ATTACHMENT_UPDATE,
00134                 FTM_LOD_UPDATE,
00135                 FTM_REGION_UPDATE,
00136                 FTM_CLEANUP,
00137                 FTM_NETWORK,
00138                 FTM_IDLE_NETWORK,
00139                 FTM_CREATE_OBJECT,
00140                 FTM_LOAD_AVATAR,
00141                 FTM_PROCESS_MESSAGES,
00142                 FTM_PROCESS_OBJECTS,
00143                 FTM_PROCESS_IMAGES,
00144                 FTM_IMAGE_UPDATE,
00145                 FTM_IMAGE_CREATE,
00146                 FTM_IMAGE_DECODE,
00147                 FTM_IMAGE_MARK_DIRTY,
00148                 FTM_PIPELINE,
00149                 FTM_VFILE_WAIT,
00150                 FTM_FLEXIBLE_UPDATE,
00151                 FTM_OCCLUSION,
00152                 FTM_OCCLUSION_READBACK,
00153                 FTM_HUD_EFFECTS,
00154                 FTM_HUD_UPDATE,
00155                 FTM_INVENTORY,
00156                 FTM_AUTO_SELECT,
00157                 FTM_ARRANGE,
00158                 FTM_FILTER,
00159                 FTM_REFRESH,
00160                 FTM_SORT,
00161                 
00162                 // Temp
00163                 FTM_TEMP1,
00164                 FTM_TEMP2,
00165                 FTM_TEMP3,
00166                 FTM_TEMP4,
00167                 FTM_TEMP5,
00168                 FTM_TEMP6,
00169                 FTM_TEMP7,
00170                 FTM_TEMP8,
00171                 
00172                 FTM_OTHER, // Special, used by display code
00173                 
00174                 FTM_NUM_TYPES
00175         };
00176         enum { FTM_HISTORY_NUM = 60 };
00177         enum { FTM_MAX_DEPTH = 64 };
00178         
00179 public:
00180         LLFastTimer(EFastTimerType type)
00181         {
00182 #if FAST_TIMER_ON
00183                 mType = type;
00184 
00185                 // These don't get counted, because they use CPU clockticks
00186                 //gTimerBins[gCurTimerBin]++;
00187                 //LLTimer::sNumTimerCalls++;
00188 
00189                 U64 cpu_clocks = get_cpu_clock_count();
00190 
00191                 sStart[sCurDepth] = cpu_clocks;
00192                 sCurDepth++;
00193 #endif
00194         };
00195         ~LLFastTimer()
00196         {
00197 #if FAST_TIMER_ON
00198                 U64 end,delta;
00199                 int i;
00200 
00201                 // These don't get counted, because they use CPU clockticks
00202                 //gTimerBins[gCurTimerBin]++;
00203                 //LLTimer::sNumTimerCalls++;
00204                 end = get_cpu_clock_count();
00205 
00206                 sCurDepth--;
00207                 delta = end - sStart[sCurDepth];
00208                 sCounter[mType] += delta;
00209                 sCalls[mType]++;
00210                 // Subtract delta from parents
00211                 for (i=0; i<sCurDepth; i++)
00212                         sStart[i] += delta;
00213 #endif
00214         }
00215 
00216         static void reset();
00217         static U64 countsPerSecond();
00218 
00219 public:
00220         static int sCurDepth;
00221         static U64 sStart[FTM_MAX_DEPTH];
00222         static U64 sCounter[FTM_NUM_TYPES];
00223         static U64 sCalls[FTM_NUM_TYPES];
00224         static U64 sCountAverage[FTM_NUM_TYPES];
00225         static U64 sCallAverage[FTM_NUM_TYPES];
00226         static U64 sCountHistory[FTM_HISTORY_NUM][FTM_NUM_TYPES];
00227         static U64 sCallHistory[FTM_HISTORY_NUM][FTM_NUM_TYPES];
00228         static S32 sCurFrameIndex;
00229         static S32 sLastFrameIndex;
00230         static int sPauseHistory;
00231         static int sResetHistory;
00232         static F64 sCPUClockFrequency;
00233         
00234 private:
00235         EFastTimerType mType;
00236 };
00237 
00238 
00239 #endif // LL_LLFASTTIMER_H

Generated on Thu Jul 1 06:08:29 2010 for Second Life Viewer by  doxygen 1.4.7