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),
_enableProcessOctreeThread(true),
_octreeProcessor(),
_inPacketsPerSecond(0),
_outPacketsPerSecond(0),
_inBytesPerSecond(0),
_outBytesPerSecond(0),
// _inPacketsPerSecond(0),
// _outPacketsPerSecond(0),
// _inBytesPerSecond(0),
// _outBytesPerSecond(0),
_nodeBoundsDisplay(this),
_previousScriptLocation(),
_applicationOverlay(),
@ -1380,10 +1380,10 @@ void Application::timer() {
_fps = (float)_frameCount / diffTime;
_inPacketsPerSecond = (float) _datagramProcessor.getInPacketCount() / diffTime;
_outPacketsPerSecond = (float) _datagramProcessor.getOutPacketCount() / diffTime;
_inBytesPerSecond = (float) _datagramProcessor.getInByteCount() / diffTime;
_outBytesPerSecond = (float) _datagramProcessor.getOutByteCount() / diffTime;
// _inPacketsPerSecond = (float) _datagramProcessor.getInPacketCount() / diffTime;
// _outPacketsPerSecond = (float) _datagramProcessor.getOutPacketCount() / diffTime;
// _inBytesPerSecond = (float) _datagramProcessor.getInByteCount() / diffTime;
// _outBytesPerSecond = (float) _datagramProcessor.getOutByteCount() / diffTime;
_frameCount = 0;
_datagramProcessor.resetCounters();

View file

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

View file

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

View file

@ -201,8 +201,8 @@ void Stats::display(
float fps,
int inPacketsPerSecond,
int outPacketsPerSecond,
int inBytesPerSecond,
int outBytesPerSecond,
int inKbitsPerSecond,
int outKbitsPerSecond,
int voxelPacketsToProcess)
{
auto glCanvas = DependencyManager::get<GLCanvas>();
@ -318,8 +318,8 @@ void Stats::display(
sprintf(packetsPerSecondString, "Packets In/Out: %d/%d", inPacketsPerSecond, outPacketsPerSecond);
char averageMegabitsPerSecond[30];
sprintf(averageMegabitsPerSecond, "Mbps In/Out: %3.2f/%3.2f",
(float)inBytesPerSecond * 8.0f / 1000000.0f,
(float)outBytesPerSecond * 8.0f / 1000000.0f);
(float)inKbitsPerSecond * 1.0f / 1000.0f,
(float)outKbitsPerSecond * 1.0f / 1000.0f);
verticalOffset += STATS_PELS_PER_LINE;
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 resetWidth(int width, int horizontalOffset);
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);
Q_INVOKABLE void setMetavoxelStats(int internal, int leaves, int sendProgress,

View file

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

View file

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