15 #include <QStringList>
26 mIntervalClock.start();
34 mIntervalClock.start();
40 mIntervalClock.restart();
47 this->
time(
"outside");
52 std::vector<Entry>::iterator iter;
53 for (iter=mTiming.begin(); iter!=mTiming.end(); ++iter)
57 iter->time.push_back(mRenderClock.restart());
63 newEntry.time.push_back(mRenderClock.restart());
64 mTiming.push_back(newEntry);
71 if (!mIntervalClock.elapsed())
73 double numberOfRenderings = mTiming.empty() ? 0 : mTiming.front().time.size();
74 double fps = 1000.0 * numberOfRenderings / mIntervalClock.elapsed();
80 return mIntervalClock.elapsed() > mInterval;
126 std::stringstream ss;
127 ss << mName <<
":\t";
128 ss <<
"Elapsed=" << mIntervalClock.elapsed() <<
" ms";
129 ss <<
"\tFPS=" << this->
getFPS() <<
" fps";
134 QStringList meanTimes;
135 QStringList maxTimes;
139 std::vector<Entry>::iterator entry;
140 for (entry=mTiming.begin(); entry!=mTiming.end(); ++entry)
142 double maxTime = this->getMaxTime(entry->time);
143 double meanTime = this->getMeanTime(entry->time);
144 totalTime += meanTime;
151 ss << QString(
"\t(total=%1)").arg(ids.join(
"+"));
152 ss << QString(
"\tMean:(%2=%3) ms/frame").arg(totalTime).arg(meanTimes.join(
"+"));
153 ss << QString(
"\tMax:(%1)").arg(maxTimes.join(
"+"));
158 double CyclicActionLogger::getMeanTime(std::vector<double> &time)
160 return std::accumulate(
time.begin(),
time.end(), 0)/
time.size();
163 double CyclicActionLogger::getMaxTime(std::vector<double> &time)
165 return *std::max_element(
time.begin(),
time.end());
170 std::vector<Entry>::iterator entry = getTimingVectorIterator(
id);
171 if(entry == mTiming.end())
173 reportWarning(
"CyclicActionLogger::getTime() unknown id: " +
id);
176 return getMeanTime(entry->time);
179 std::vector<CyclicActionLogger::Entry>::iterator CyclicActionLogger::getTimingVectorIterator(QString
id)
181 std::vector<Entry>::iterator entry;
182 for (entry=mTiming.begin(); entry!=mTiming.end(); ++entry)
192 double totalTime = 0;
193 std::vector<Entry>::iterator entry;
194 for (entry=mTiming.begin(); entry!=mTiming.end(); ++entry)
196 if(entry->id !=
"outside")
198 double meanTime = this->getMeanTime(entry->time);
199 totalTime += meanTime;