show how many times per second Application::idle is called

This commit is contained in:
Seth Alves 2015-08-18 01:37:11 -07:00
parent 51f0ab3d7c
commit 551f0aaba3
5 changed files with 29 additions and 6 deletions

View file

@ -47,6 +47,11 @@ Item {
font.pixelSize: root.fontSize font.pixelSize: root.fontSize
text: "Framerate: " + root.framerate text: "Framerate: " + root.framerate
} }
Text {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Simrate: " + root.simrate
}
Text { Text {
color: root.fontColor; color: root.fontColor;
font.pixelSize: root.fontSize font.pixelSize: root.fontSize

View file

@ -89,7 +89,6 @@
#include <SceneScriptingInterface.h> #include <SceneScriptingInterface.h>
#include <ScriptCache.h> #include <ScriptCache.h>
#include <SettingHandle.h> #include <SettingHandle.h>
#include <SimpleAverage.h>
#include <SoundCache.h> #include <SoundCache.h>
#include <TextureCache.h> #include <TextureCache.h>
#include <Tooltip.h> #include <Tooltip.h>
@ -2003,19 +2002,27 @@ void Application::checkFPS() {
void Application::idle() { void Application::idle() {
PROFILE_RANGE(__FUNCTION__); PROFILE_RANGE(__FUNCTION__);
static SimpleAverage<float> interIdleDurations;
static uint64_t lastIdleStart{ 0 };
static uint64_t lastIdleEnd{ 0 }; static uint64_t lastIdleEnd{ 0 };
uint64_t now = usecTimestampNow();
uint64_t idleStartToStartDuration = now - lastIdleStart;
if (lastIdleStart > 0 && idleStartToStartDuration > 0) {
_simsPerSecond.updateAverage((float)USECS_PER_SECOND / (float)idleStartToStartDuration);
}
lastIdleStart = now;
if (lastIdleEnd != 0) { if (lastIdleEnd != 0) {
uint64_t now = usecTimestampNow(); _interIdleDurations.update(now - lastIdleEnd);
interIdleDurations.update(now - lastIdleEnd);
static uint64_t lastReportTime = now; static uint64_t lastReportTime = now;
if ((now - lastReportTime) >= (USECS_PER_SECOND)) { if ((now - lastReportTime) >= (USECS_PER_SECOND)) {
static QString LOGLINE("Average inter-idle time: %1 us for %2 samples"); static QString LOGLINE("Average inter-idle time: %1 us for %2 samples");
if (Menu::getInstance()->isOptionChecked(MenuOption::LogExtraTimings)) { if (Menu::getInstance()->isOptionChecked(MenuOption::LogExtraTimings)) {
qCDebug(interfaceapp_timing) << LOGLINE.arg((int)interIdleDurations.getAverage()).arg(interIdleDurations.getCount()); qCDebug(interfaceapp_timing) << LOGLINE.arg((int)_interIdleDurations.getAverage()).arg(_interIdleDurations.getCount());
} }
interIdleDurations.reset(); _interIdleDurations.reset();
lastReportTime = now; lastReportTime = now;
} }
} }

View file

@ -38,6 +38,8 @@
#include <ViewFrustum.h> #include <ViewFrustum.h>
#include <plugins/PluginContainer.h> #include <plugins/PluginContainer.h>
#include <plugins/PluginManager.h> #include <plugins/PluginManager.h>
#include <SimpleAverage.h>
#include <SimpleMovingAverage.h>
#include "AudioClient.h" #include "AudioClient.h"
#include "Bookmarks.h" #include "Bookmarks.h"
@ -350,6 +352,9 @@ public:
const QRect& getMirrorViewRect() const { return _mirrorViewRect; } const QRect& getMirrorViewRect() const { return _mirrorViewRect; }
float getAverageInterIdleDuration() { return _interIdleDurations.getAverage(); }
float getAverageSimsPerSecond() { return _simsPerSecond.getAverage(); }
signals: signals:
/// Fired when we're simulating; allows external parties to hook in. /// Fired when we're simulating; allows external parties to hook in.
@ -681,6 +686,9 @@ private:
EntityItemID _keyboardFocusedItem; EntityItemID _keyboardFocusedItem;
quint64 _lastAcceptedKeyPress = 0; quint64 _lastAcceptedKeyPress = 0;
SimpleAverage<float> _interIdleDurations;
SimpleMovingAverage _simsPerSecond;
}; };
#endif // hifi_Application_h #endif // hifi_Application_h

View file

@ -114,6 +114,7 @@ void Stats::updateStats() {
STAT_UPDATE(avatarCount, avatarManager->size() - 1); STAT_UPDATE(avatarCount, avatarManager->size() - 1);
STAT_UPDATE(serverCount, nodeList->size()); STAT_UPDATE(serverCount, nodeList->size());
STAT_UPDATE(framerate, (int)qApp->getFps()); STAT_UPDATE(framerate, (int)qApp->getFps());
STAT_UPDATE(simrate, (int)Application::getInstance()->getAverageSimsPerSecond());
auto bandwidthRecorder = DependencyManager::get<BandwidthRecorder>(); auto bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
STAT_UPDATE(packetInCount, bandwidthRecorder->getCachedTotalAverageInputPacketsPerSecond()); STAT_UPDATE(packetInCount, bandwidthRecorder->getCachedTotalAverageInputPacketsPerSecond());

View file

@ -30,6 +30,7 @@ class Stats : public QQuickItem {
STATS_PROPERTY(int, serverCount, 0) STATS_PROPERTY(int, serverCount, 0)
STATS_PROPERTY(int, framerate, 0) STATS_PROPERTY(int, framerate, 0)
STATS_PROPERTY(int, simrate, 0)
STATS_PROPERTY(int, avatarCount, 0) STATS_PROPERTY(int, avatarCount, 0)
STATS_PROPERTY(int, packetInCount, 0) STATS_PROPERTY(int, packetInCount, 0)
STATS_PROPERTY(int, packetOutCount, 0) STATS_PROPERTY(int, packetOutCount, 0)
@ -95,6 +96,7 @@ signals:
void timingExpandedChanged(); void timingExpandedChanged();
void serverCountChanged(); void serverCountChanged();
void framerateChanged(); void framerateChanged();
void simrateChanged();
void avatarCountChanged(); void avatarCountChanged();
void packetInCountChanged(); void packetInCountChanged();
void packetOutCountChanged(); void packetOutCountChanged();