Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 30, 2008, 1:05:27 PM (16 years ago)
Author:
scheusso
Message:

Statistics of GSGraphics have a config value more now: avgLength
It defines the time period/age of the statistics data (fps, ticktime)

Location:
code/branches/presentation/src/orxonox/gamestates
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/orxonox/gamestates/GSGraphics.cc

    r2485 r2548  
    107107        SetConfigValue(ogreLogLevelCritical_, 2)
    108108            .description("Corresponding orxonox debug level for ogre Critical");
    109         SetConfigValue(statisticsRefreshCycle_, 200000)
     109        SetConfigValue(statisticsRefreshCycle_, 250000)
    110110            .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
     111        SetConfigValue(statisticsAvgLength_, 1000000)
     112            .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
    111113        SetConfigValue(defaultMasterKeybindings_, "def_masterKeybindings.ini")
    112114            .description("Filename of default master keybindings.");
     
    240242    void GSGraphics::ticked(const Clock& time)
    241243    {
    242         unsigned long long timeBeforeTick = time.getRealMicroseconds();
     244        uint64_t timeBeforeTick = time.getRealMicroseconds();
    243245        float dt = time.getDeltaTime();
    244246
     
    255257        }
    256258
    257         unsigned long long timeAfterTick = time.getRealMicroseconds();
    258 
     259        uint64_t timeAfterTick = time.getRealMicroseconds();
     260
     261        statisticsTickInfo tickInfo = {timeAfterTick, timeAfterTick-timeBeforeTick};
     262        statisticsTickTimes_.push_front( tickInfo );
    259263        tickTime_ += (unsigned int)(timeAfterTick - timeBeforeTick);
    260264        if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_)
    261265        {
    262             GraphicsEngine::getInstance().setAverageTickTime(
    263                 (float)tickTime_ * 0.001f / (frameCount_ - statisticsStartCount_));
    264             float avgFPS = (float)(frameCount_ - statisticsStartCount_)
    265                 / (timeAfterTick - statisticsStartTime_) * 1000000.0;
     266            while( (statisticsTickTimes_.size()!=0) && (statisticsTickTimes_.back().tickTime < timeAfterTick - statisticsAvgLength_ ) )
     267                statisticsTickTimes_.pop_back();
     268            std::deque<statisticsTickInfo>::iterator it = statisticsTickTimes_.begin();
     269            uint32_t periodTickTime = 0;
     270            unsigned int periodNrOfTicks = 0;
     271            while ( it!=statisticsTickTimes_.end() )
     272            {
     273                periodTickTime += it->tickLength;
     274                periodNrOfTicks++;
     275                ++it;
     276            }
     277            float avgFPS = (float)periodNrOfTicks/(statisticsTickTimes_.front().tickTime - statisticsTickTimes_.back().tickTime)*1000000.0;
     278            float avgTickTime = (float)periodTickTime/periodNrOfTicks/1000.0;
     279            //float avgFPS = (float)statisticsTickTimes_.size()/statisticsAvgLength_*1000000.0;
    266280            GraphicsEngine::getInstance().setAverageFramesPerSecond(avgFPS);
     281            //GraphicsEngine::getInstance().setAverageTickTime(
     282              //(float)tickTime_ * 0.001f / (frameCount_ - statisticsStartCount_));
     283            GraphicsEngine::getInstance().setAverageTickTime( avgTickTime );
    267284
    268285            tickTime_ = 0;
  • code/branches/presentation/src/orxonox/gamestates/GSGraphics.h

    r2485 r2548  
    3737#include "GSRoot.h"
    3838
     39#include <deque>
     40
    3941namespace orxonox
    4042{
     43    struct statisticsTickInfo{
     44        uint64_t    tickTime;
     45        uint32_t    tickLength;
     46    };
     47   
    4148    class _OrxonoxExport GSGraphics : public GameState<GSRoot>, public OrxonoxClass,
    4249                                      public Ogre::WindowEventListener, public Ogre::LogListener
     
    97104        unsigned long         frameCount_;
    98105        unsigned int          statisticsRefreshCycle_;
     106        unsigned int          statisticsAvgLength_;
    99107        unsigned long long    statisticsStartTime_;
    100108        unsigned long         statisticsStartCount_;
     109        std::deque<statisticsTickInfo>
     110            statisticsTickTimes_;
    101111        unsigned int          tickTime_;
    102112        XMLFile*              debugOverlay_;
Note: See TracChangeset for help on using the changeset viewer.