Ignore:
Timestamp:
09/06/05 18:18:47 (19 years ago)
Author:
mattausch
Message:

refined measurements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h

    r254 r259  
    1919using namespace Ogre; 
    2020 
    21  
     21/** Struct storing walktrough statistics 
     22*/ 
     23struct WalkthroughStats 
     24{ 
     25public: 
     26 
     27        unsigned long mAccFps; 
     28        unsigned long mBestFps; 
     29        unsigned long mWorstFps; 
     30        unsigned long mAccTris; 
     31        unsigned long mAccQueryCulledNodes; 
     32        unsigned long mAccFrustumCulledNodes; 
     33        unsigned long mFrameCount; 
     34        unsigned long mAccRenderedNodes; 
     35         
     36        WalkthroughStats():  
     37        mAccFps(0), mBestFps(0), mWorstFps(0), mAccTris(0), 
     38        mAccQueryCulledNodes(0), mAccFrustumCulledNodes(0), 
     39        mFrameCount(0), mAccRenderedNodes(0) 
     40        {} 
     41 
     42        void Reset() 
     43        { 
     44                mAccFps = mBestFps = mWorstFps = mAccTris = mAccQueryCulledNodes = mAccFrustumCulledNodes = mFrameCount = mAccRenderedNodes = 0; 
     45        } 
     46 
     47        void UpdateFrame(int currentFps, int bestFps, int worstFps, int renderedTris, int renderedNodes, int queryCulledNodes, int frustumCulledNodes) 
     48        { 
     49                mAccFps += currentFps; 
     50                mBestFps = bestFps; 
     51                mWorstFps = worstFps; 
     52 
     53                // accumulated #triangles (M) 
     54                mAccTris += renderedTris / 1000; 
     55                mAccRenderedNodes += renderedNodes; 
     56                mAccQueryCulledNodes += queryCulledNodes; 
     57                mAccFrustumCulledNodes += frustumCulledNodes; 
     58         
     59                ++ mFrameCount; 
     60        } 
     61 
     62        void Print(std::ostream &d, const std::string &algorithmName) const 
     63        { 
     64                // compuate average fps and triangle count 
     65                float avgFps = (float)mAccFps / (float)mFrameCount; 
     66                float avgTris = (float)mAccTris / (float)mFrameCount; 
     67                float avgFrustumCulledNodes = 0; 
     68                float avgRenderedNodes = 0; 
     69                float avgQueryCulledNodes = 0; 
     70                 
     71                if (mFrameCount != 0) 
     72                { 
     73                        avgFrustumCulledNodes = (float)mAccFrustumCulledNodes / (float)mFrameCount; 
     74                        avgQueryCulledNodes  = (float)mAccQueryCulledNodes / (float)mFrameCount; 
     75                        avgRenderedNodes = (float)mAccRenderedNodes / (float) mFrameCount; 
     76                } 
     77 
     78                //-- write out stats for recorded walkthrough 
     79                d << "Algorithm: " << algorithmName << "\n" 
     80                        << "avg. FPS: " << avgFps << "\n" 
     81                        << "best FPS: " << mBestFps << "\n" 
     82                        << "worst FPS: " << mWorstFps << "\n" 
     83                        << "avg. #triangles: " << avgTris << " M\n" 
     84                        << "#frames: " << mFrameCount << "\n" 
     85                        << "avg. #query culled nodes: " << avgFrustumCulledNodes << "\n" 
     86                        << "avg. #frustum culled nodes: " << avgQueryCulledNodes << "\n" 
     87                        << "avg. #rendered nodes: " << avgRenderedNodes << "\n"; 
     88        } 
     89 
     90}; 
    2291 
    2392/** Frame listener specialised for terrains. 
     
    39108 
    40109   ~TerrainFrameListener(); 
    41  
    42110 
    43111   bool frameStarted(const FrameEvent& evt); 
     
    184252        void initVisStatsOverlay(); 
    185253        void initQueryOverlay(); 
    186  
    187         void resetStats(); 
    188254         
    189255        SceneManager *mSceneMgr;           // A pointer to the scene manager 
     
    206272        /// the newly created object 
    207273        SceneNode *mCurrentObject;     
    208 /// HACK 
    209 float mDemoFps; 
    210 bool mUseDemoFps; 
     274 
     275        WalkthroughStats mWalkthroughStats; 
     276 
     277        /// HACK for demo 
     278        float mDemoFps; 
     279        bool mUseDemoFps; 
     280 
    211281        OverlayElement *mAlgorithmInfo; 
    212282        OverlayElement *mThresholdInfo; 
     
    301371        bool mShiftPressed; 
    302372        bool mShowQueryStats; 
    303  
    304         unsigned long mAvgFps; 
    305         unsigned long mFrameCount; 
    306  
     373         
    307374        //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 
    308375        PlatformQueryManager *mQueryManager; 
Note: See TracChangeset for help on using the changeset viewer.