use BandwidthRecorder rather than recompute Mbps and pps in Application

This commit is contained in:
Seth Alves 2015-01-31 20:40:18 -08:00
parent bee895ba0a
commit fc07ecf83d
7 changed files with 32 additions and 31 deletions

View file

@ -241,10 +241,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_mousePressed(false), _mousePressed(false),
_enableProcessOctreeThread(true), _enableProcessOctreeThread(true),
_octreeProcessor(), _octreeProcessor(),
_inPacketsPerSecond(0), // _inPacketsPerSecond(0),
_outPacketsPerSecond(0), // _outPacketsPerSecond(0),
_inBytesPerSecond(0), // _inBytesPerSecond(0),
_outBytesPerSecond(0), // _outBytesPerSecond(0),
_nodeBoundsDisplay(this), _nodeBoundsDisplay(this),
_previousScriptLocation(), _previousScriptLocation(),
_applicationOverlay(), _applicationOverlay(),
@ -1380,10 +1380,10 @@ void Application::timer() {
_fps = (float)_frameCount / diffTime; _fps = (float)_frameCount / diffTime;
_inPacketsPerSecond = (float) _datagramProcessor.getInPacketCount() / diffTime; // _inPacketsPerSecond = (float) _datagramProcessor.getInPacketCount() / diffTime;
_outPacketsPerSecond = (float) _datagramProcessor.getOutPacketCount() / diffTime; // _outPacketsPerSecond = (float) _datagramProcessor.getOutPacketCount() / diffTime;
_inBytesPerSecond = (float) _datagramProcessor.getInByteCount() / diffTime; // _inBytesPerSecond = (float) _datagramProcessor.getInByteCount() / diffTime;
_outBytesPerSecond = (float) _datagramProcessor.getOutByteCount() / diffTime; // _outBytesPerSecond = (float) _datagramProcessor.getOutByteCount() / diffTime;
_frameCount = 0; _frameCount = 0;
_datagramProcessor.resetCounters(); _datagramProcessor.resetCounters();

View file

@ -208,10 +208,10 @@ public:
Overlays& getOverlays() { return _overlays; } Overlays& getOverlays() { return _overlays; }
float getFps() const { return _fps; } float getFps() const { return _fps; }
float getInPacketsPerSecond() const { return _inPacketsPerSecond; } // float getInPacketsPerSecond() const { return _inPacketsPerSecond; }
float getOutPacketsPerSecond() const { return _outPacketsPerSecond; } // float getOutPacketsPerSecond() const { return _outPacketsPerSecond; }
float getInBytesPerSecond() const { return _inBytesPerSecond; } // float getInBytesPerSecond() const { return _inBytesPerSecond; }
float getOutBytesPerSecond() const { return _outBytesPerSecond; } // float getOutBytesPerSecond() const { return _outBytesPerSecond; }
const glm::vec3& getViewMatrixTranslation() const { return _viewMatrixTranslation; } const glm::vec3& getViewMatrixTranslation() const { return _viewMatrixTranslation; }
void setViewMatrixTranslation(const glm::vec3& translation) { _viewMatrixTranslation = translation; } void setViewMatrixTranslation(const glm::vec3& translation) { _viewMatrixTranslation = translation; }
@ -535,10 +535,10 @@ private:
OctreePacketProcessor _octreeProcessor; OctreePacketProcessor _octreeProcessor;
EntityEditPacketSender _entityEditSender; EntityEditPacketSender _entityEditSender;
int _inPacketsPerSecond; // int _inPacketsPerSecond;
int _outPacketsPerSecond; // int _outPacketsPerSecond;
int _inBytesPerSecond; // int _inBytesPerSecond;
int _outBytesPerSecond; // int _outBytesPerSecond;
StDev _idleLoopStdev; StDev _idleLoopStdev;
float _idleLoopMeasuredJitter; float _idleLoopMeasuredJitter;

View file

@ -904,6 +904,7 @@ void ApplicationOverlay::renderAudioMeter() {
void ApplicationOverlay::renderStatsAndLogs() { void ApplicationOverlay::renderStatsAndLogs() {
Application* application = Application::getInstance(); Application* application = Application::getInstance();
BandwidthRecorder* bandwidthRecorder = Application::getInstance()->getBandwidthRecorder();
auto glCanvas = DependencyManager::get<GLCanvas>(); auto glCanvas = DependencyManager::get<GLCanvas>();
const OctreePacketProcessor& octreePacketProcessor = application->getOctreePacketProcessor(); const OctreePacketProcessor& octreePacketProcessor = application->getOctreePacketProcessor();
@ -919,10 +920,10 @@ void ApplicationOverlay::renderStatsAndLogs() {
int voxelPacketsToProcess = octreePacketProcessor.packetsToProcessCount(); int voxelPacketsToProcess = octreePacketProcessor.packetsToProcessCount();
// Onscreen text about position, servers, etc // Onscreen text about position, servers, etc
Stats::getInstance()->display(WHITE_TEXT, horizontalOffset, application->getFps(), Stats::getInstance()->display(WHITE_TEXT, horizontalOffset, application->getFps(),
application->getInPacketsPerSecond(), bandwidthRecorder->totalChannel->getAverageInputPacketsPerSecond(),
application->getOutPacketsPerSecond(), bandwidthRecorder->totalChannel->getAverageOutputPacketsPerSecond(),
application->getInBytesPerSecond(), bandwidthRecorder->totalChannel->getAverageInputKilobitsPerSecond(),
application->getOutBytesPerSecond(), bandwidthRecorder->totalChannel->getAverageOutputKilobitsPerSecond(),
voxelPacketsToProcess); voxelPacketsToProcess);
} }

View file

@ -201,8 +201,8 @@ void Stats::display(
float fps, float fps,
int inPacketsPerSecond, int inPacketsPerSecond,
int outPacketsPerSecond, int outPacketsPerSecond,
int inBytesPerSecond, int inKbitsPerSecond,
int outBytesPerSecond, int outKbitsPerSecond,
int voxelPacketsToProcess) int voxelPacketsToProcess)
{ {
auto glCanvas = DependencyManager::get<GLCanvas>(); auto glCanvas = DependencyManager::get<GLCanvas>();
@ -318,8 +318,8 @@ void Stats::display(
sprintf(packetsPerSecondString, "Packets In/Out: %d/%d", inPacketsPerSecond, outPacketsPerSecond); sprintf(packetsPerSecondString, "Packets In/Out: %d/%d", inPacketsPerSecond, outPacketsPerSecond);
char averageMegabitsPerSecond[30]; char averageMegabitsPerSecond[30];
sprintf(averageMegabitsPerSecond, "Mbps In/Out: %3.2f/%3.2f", sprintf(averageMegabitsPerSecond, "Mbps In/Out: %3.2f/%3.2f",
(float)inBytesPerSecond * 8.0f / 1000000.0f, (float)inKbitsPerSecond * 1.0f / 1000.0f,
(float)outBytesPerSecond * 8.0f / 1000000.0f); (float)outKbitsPerSecond * 1.0f / 1000.0f);
verticalOffset += STATS_PELS_PER_LINE; verticalOffset += STATS_PELS_PER_LINE;
drawText(horizontalOffset, verticalOffset, scale, rotation, font, packetsPerSecondString, color); drawText(horizontalOffset, verticalOffset, scale, rotation, font, packetsPerSecondString, color);

View file

@ -30,7 +30,7 @@ public:
void checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseDragStartedY, int horizontalOffset); void checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseDragStartedY, int horizontalOffset);
void resetWidth(int width, int horizontalOffset); void resetWidth(int width, int horizontalOffset);
void display(const float* color, int horizontalOffset, float fps, int inPacketsPerSecond, int outPacketsPerSecond, void display(const float* color, int horizontalOffset, float fps, int inPacketsPerSecond, int outPacketsPerSecond,
int inBytesPerSecond, int outBytesPerSecond, int voxelPacketsToProcess); int inKbitsPerSecond, int outKbitsPerSecond, int voxelPacketsToProcess);
bool includeTimingRecord(const QString& name); bool includeTimingRecord(const QString& name);
Q_INVOKABLE void setMetavoxelStats(int internal, int leaves, int sendProgress, Q_INVOKABLE void setMetavoxelStats(int internal, int leaves, int sendProgress,

View file

@ -52,8 +52,8 @@ class BandwidthRecorder : public QObject {
unsigned colorRGBA; unsigned colorRGBA;
private: private:
SimpleMovingAverage _input; SimpleMovingAverage _input = SimpleMovingAverage(1000);
SimpleMovingAverage _output; SimpleMovingAverage _output = SimpleMovingAverage(1000);
}; };
// create the channels we keep track of // create the channels we keep track of

View file

@ -47,8 +47,8 @@ LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short
_localSockAddr(), _localSockAddr(),
_publicSockAddr(), _publicSockAddr(),
_stunSockAddr(STUN_SERVER_HOSTNAME, STUN_SERVER_PORT), _stunSockAddr(STUN_SERVER_HOSTNAME, STUN_SERVER_PORT),
_numCollectedPackets(0), // _numCollectedPackets(0),
_numCollectedBytes(0), // _numCollectedBytes(0),
_packetStatTimer() _packetStatTimer()
{ {
static bool firstCall = true; static bool firstCall = true;
@ -234,8 +234,8 @@ qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSock
} }
// stat collection for packets // stat collection for packets
++_numCollectedPackets; // ++_numCollectedPackets;
_numCollectedBytes += datagram.size(); // _numCollectedBytes += datagram.size();
qint64 bytesWritten = _nodeSocket.writeDatagram(datagramCopy, qint64 bytesWritten = _nodeSocket.writeDatagram(datagramCopy,
destinationSockAddr.getAddress(), destinationSockAddr.getPort()); destinationSockAddr.getAddress(), destinationSockAddr.getPort());