Changeset 2548 for code/branches/presentation/src/orxonox
- Timestamp:
- Dec 30, 2008, 1:05:27 PM (16 years ago)
- Location:
- code/branches/presentation/src/orxonox/gamestates
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/gamestates/GSGraphics.cc
r2485 r2548 107 107 SetConfigValue(ogreLogLevelCritical_, 2) 108 108 .description("Corresponding orxonox debug level for ogre Critical"); 109 SetConfigValue(statisticsRefreshCycle_, 2 00000)109 SetConfigValue(statisticsRefreshCycle_, 250000) 110 110 .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."); 111 113 SetConfigValue(defaultMasterKeybindings_, "def_masterKeybindings.ini") 112 114 .description("Filename of default master keybindings."); … … 240 242 void GSGraphics::ticked(const Clock& time) 241 243 { 242 u nsigned long longtimeBeforeTick = time.getRealMicroseconds();244 uint64_t timeBeforeTick = time.getRealMicroseconds(); 243 245 float dt = time.getDeltaTime(); 244 246 … … 255 257 } 256 258 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 ); 259 263 tickTime_ += (unsigned int)(timeAfterTick - timeBeforeTick); 260 264 if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_) 261 265 { 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; 266 280 GraphicsEngine::getInstance().setAverageFramesPerSecond(avgFPS); 281 //GraphicsEngine::getInstance().setAverageTickTime( 282 //(float)tickTime_ * 0.001f / (frameCount_ - statisticsStartCount_)); 283 GraphicsEngine::getInstance().setAverageTickTime( avgTickTime ); 267 284 268 285 tickTime_ = 0; -
code/branches/presentation/src/orxonox/gamestates/GSGraphics.h
r2485 r2548 37 37 #include "GSRoot.h" 38 38 39 #include <deque> 40 39 41 namespace orxonox 40 42 { 43 struct statisticsTickInfo{ 44 uint64_t tickTime; 45 uint32_t tickLength; 46 }; 47 41 48 class _OrxonoxExport GSGraphics : public GameState<GSRoot>, public OrxonoxClass, 42 49 public Ogre::WindowEventListener, public Ogre::LogListener … … 97 104 unsigned long frameCount_; 98 105 unsigned int statisticsRefreshCycle_; 106 unsigned int statisticsAvgLength_; 99 107 unsigned long long statisticsStartTime_; 100 108 unsigned long statisticsStartCount_; 109 std::deque<statisticsTickInfo> 110 statisticsTickTimes_; 101 111 unsigned int tickTime_; 102 112 XMLFile* debugOverlay_;
Note: See TracChangeset
for help on using the changeset viewer.