- Timestamp:
- Dec 30, 2008, 3:27:39 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/gamestates/GSRoot.cc
r2485 r2549 89 89 void GSRoot::setConfigValues() 90 90 { 91 SetConfigValue(statisticsRefreshCycle_, 250000) 92 .description("Sets the time in microseconds interval at which average fps, etc. get updated."); 93 SetConfigValue(statisticsAvgLength_, 1000000) 94 .description("Sets the time in microseconds interval at which average fps, etc. gets calculated."); 91 95 } 92 96 … … 98 102 // reset game speed to normal 99 103 timeFactor_ = 1.0f; 104 105 // reset frame counter 106 this->frameCount_ = 0; 107 this->statisticsStartTime_ = 0; 108 this->statisticsTickTimes_.clear(); 109 this->periodTickTime_ = 0; 110 this->avgFPS_ = 0.0f; 111 this->avgTickTime_ = 0.0f; 100 112 101 113 // Create the lua interface … … 189 201 void GSRoot::ticked(const Clock& time) 190 202 { 203 uint64_t timeBeforeTick = time.getRealMicroseconds(); 204 191 205 TclThreadManager::getInstance().tick(time.getDeltaTime()); 192 206 … … 206 220 /*** HACK *** HACK ***/ 207 221 222 uint64_t timeAfterTick = time.getRealMicroseconds(); 223 224 // STATISTICS 225 statisticsTickInfo tickInfo = {timeAfterTick, timeAfterTick - timeBeforeTick}; 226 statisticsTickTimes_.push_back(tickInfo); 227 228 // Ticks GSGraphics or GSDedicated 208 229 this->tickChild(time); 230 231 // Note: tickInfo.tickLength is modified by GSGraphics or GSDedicated! 232 this->periodTickTime_ += tickInfo.tickLength; 233 if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_) 234 { 235 while (statisticsTickTimes_.front().tickTime < timeAfterTick - statisticsAvgLength_) 236 { 237 this->periodTickTime_ -= this->statisticsTickTimes_.front().tickLength; 238 this->statisticsTickTimes_.pop_front(); 239 } 240 241 uint32_t framesPerPeriod = this->statisticsTickTimes_.size(); 242 this->avgFPS_ = (float)framesPerPeriod / (tickInfo.tickTime - this->statisticsTickTimes_.front().tickTime) * 1000000.0; 243 this->avgTickTime_ = (float)this->periodTickTime_ / framesPerPeriod / 1000.0; 244 245 statisticsStartTime_ = timeAfterTick; 246 } 247 248 ++this->frameCount_; 209 249 } 210 250
Note: See TracChangeset
for help on using the changeset viewer.