void Stopwatch::notifyStop(const std::string& option, const std::string& stopWatchName) { StopWatchOptions::iterator option_it = options.find(option); if (option_it == options.end()) return; StopwatchItems::iterator sw_it = (*option_it).second.find(stopWatchName); if (sw_it == (*option_it).second.end()) // could happen if option got enabled just now return; notifyStop((*sw_it).second, option, stopWatchName); }
void PUParticleSystem3D::forceStopParticleSystem() { if (_render) _render->notifyStop(); for (auto &it : _observers){ it->notifyStop(); } for (auto& it : _emitters) { auto emitter = static_cast<PUEmitter*>(it); emitter->notifyStop(); } for (auto& it : _affectors) { auto affector = static_cast<PUAffector*>(it); affector->notifyStop(); } unscheduleUpdate(); unPrepared(); }
void Stopwatch::notifyStop(StopwatchItem& stopwatchItem, const std::string& option, const std::string& stopWatchName) { if (stopwatchItem.option != option || stopwatchItem.name != stopWatchName) { notifyStop(option, stopWatchName); return; } stopwatchItem.stop = getCurrentMicroTime(); stopwatchItem.isValid = true; // update the statistics of the item stopwatchItem.n++; Millisecond value = Millisecond(stopwatchItem.stop - stopwatchItem.start); stopwatchItem.min = std::min(stopwatchItem.min, value); stopwatchItem.max = std::max(stopwatchItem.max, value); // update the mean iteratively // c(n) = c(n-1) + (x_n - c(n-1))/n stopwatchItem.mean += (value - stopwatchItem.mean) / (double)stopwatchItem.n; stopwatchItem.lastValue = value; }
void Processor::setScheduledState(ScheduledState state) { state_ = state; if (state == STOPPED) { notifyStop(); } }