add ability to display domain connection times

This commit is contained in:
Stephen Birarda 2015-05-26 15:22:25 -07:00
parent d1489c50fe
commit 61029fd0b1
8 changed files with 178 additions and 184 deletions

View file

@ -472,7 +472,11 @@ Menu::Menu() {
addActionToQMenuAndActionHash(networkMenu, MenuOption::DiskCacheEditor, 0,
dialogsManager.data(), SLOT(toggleDiskCacheEditor()));
addActionToQMenuAndActionHash(networkMenu, MenuOption::ShowDSConnectTable, 0,
dialogsManager.data(), SLOT(showDomainConnectionDialog()));
MenuWrapper* timingMenu = developerMenu->addMenu("Timing and Stats");
MenuWrapper* perfTimerMenu = timingMenu->addMenu("Performance Timer");
addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::DisplayDebugTimingDetails, 0, false);
addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::OnlyDisplayTopTen, 0, true);

View file

@ -262,6 +262,7 @@ namespace MenuOption {
const QString RunTimingTests = "Run Timing Tests";
const QString ScriptEditor = "Script Editor...";
const QString ScriptedMotorControl = "Enable Scripted Motor Control";
const QString ShowDSConnectTable = "Show Domain Connection Timing";
const QString ShowBordersEntityNodes = "Show Entity Nodes";
const QString ShowIKConstraints = "Show IK Constraints";
const QString SimpleShadows = "Simple";

View file

@ -24,6 +24,7 @@
#include "BandwidthDialog.h"
#include "CachesSizeDialog.h"
#include "DiskCacheEditor.h"
#include "DomainConnectionDialog.h"
#include "HMDToolsDialog.h"
#include "LodToolsDialog.h"
#include "LoginDialog.h"
@ -176,3 +177,12 @@ void DialogsManager::showIRCLink() {
_ircInfoBox->raise();
}
void DialogsManager::showDomainConnectionDialog() {
if (!_domainConnectionDialog) {
// if the dialog already exists we delete it so the connection data is refreshed
maybeCreateDialog(_domainConnectionDialog);
_domainConnectionDialog->show();
_domainConnectionDialog->raise();
}
}

View file

@ -34,6 +34,7 @@ class PreferencesDialog;
class ScriptEditorWindow;
class QMessageBox;
class AvatarAppearanceDialog;
class DomainConnectionDialog;
class DialogsManager : public QObject, public Dependency {
Q_OBJECT
@ -62,6 +63,7 @@ public slots:
void showScriptEditor();
void showIRCLink();
void changeAvatarAppearance();
void showDomainConnectionDialog();
private slots:
void toggleToolWindow();
@ -98,6 +100,7 @@ private:
QPointer<PreferencesDialog> _preferencesDialog;
QPointer<ScriptEditorWindow> _scriptEditor;
QPointer<AvatarAppearanceDialog> _avatarAppearanceDialog;
QPointer<DomainConnectionDialog> _domainConnectionDialog;
};
#endif // hifi_DialogsManager_h

View file

@ -0,0 +1,74 @@
//
// DomainConnectionDialog.cpp
// interface/src/ui
//
// Created by Stephen Birarda on 05/26/15.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <QtCore/QMetaEnum>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QTableWidget>
#include <NodeList.h>
#include <NumericalConstants.h>
#include "DomainConnectionDialog.h"
DomainConnectionDialog::DomainConnectionDialog(QWidget* parent) :
QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint)
{
setWindowTitle("Domain Connection Timing");
setAttribute(Qt::WA_DeleteOnClose);
// setup a QTableWidget so we can populate it with our values
QTableWidget* timeTable = new QTableWidget;
const QStringList TABLE_HEADERS = QStringList() << "Name" << "Timestamp (ms)" << "Delta (ms)" << "Time elapsed (ms)";
timeTable->setHorizontalHeaderLabels(TABLE_HEADERS);
timeTable->setColumnCount(TABLE_HEADERS.size());
// ask the NodeList for the current values for connection times
QMap<NodeList::ConnectionStep, quint64> times = DependencyManager::get<NodeList>()->getLastConnectionTimes();
timeTable->setRowCount(times.size());
// setup our data with the values from the NodeList
quint64 firstStepTime = times[NodeList::ConnectionStep::LookupAddress] / USECS_PER_MSEC;
quint64 lastStepTime = firstStepTime;
int thisRow = 0;
const QMetaObject &nodeListMeta = NodeList::staticMetaObject;
QMetaEnum stepEnum = nodeListMeta.enumerator(nodeListMeta.indexOfEnumerator("ConnectionStep"));
for (int i = 0; i < stepEnum.keyCount(); i++) {
NodeList::ConnectionStep step = static_cast<NodeList::ConnectionStep>(i);
if (times.contains(step)) {
// When did this step occur, how long since the last step, how long since the start?
quint64 stepTime = times[step] / USECS_PER_MSEC;
quint64 delta = (stepTime - lastStepTime);
quint64 elapsed = stepTime - firstStepTime;
lastStepTime = stepTime;
// setup the columns for this row in the table
timeTable->setItem(thisRow, 0, new QTableWidgetItem(stepEnum.valueToKey(i)));
timeTable->setItem(thisRow, 1, new QTableWidgetItem(QString::number(stepTime)));
timeTable->setItem(thisRow, 2, new QTableWidgetItem(QString::number(delta)));
timeTable->setItem(thisRow, 3, new QTableWidgetItem(QString::number(elapsed)));
++thisRow;
}
}
QHBoxLayout* hBoxLayout = new QHBoxLayout;
hBoxLayout->addWidget(timeTable);
setLayout(hBoxLayout);
}

View file

@ -0,0 +1,25 @@
//
// DomainConnectionDialog.h
// interface/src/ui
//
// Created by Stephen Birarda on 05/26/15.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_DomainConnectionDialog_h
#define hifi_DomainConnectionDialog_h
#pragma once
#include <QtWidgets/QDialog>
class DomainConnectionDialog : public QDialog {
Q_OBJECT
public:
DomainConnectionDialog(QWidget* parent);
};
#endif // hifi_DomainConnectionDialog_h

View file

@ -1,82 +0,0 @@
//
// DomainConnectionTableModel.cpp
// interface/src/ui
//
// Created by Stephen Birarda on 05/26/15.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <QtCore/QMetaEnum>
#include <NodeList.h>
#include <NumericalConstants.h>
#include "DomainConnectionTableModel.h"
DomainConnectionTableModel::DomainConnectionTableModel(QObject* parent) :
QAbstractTableModel(parent)
{
// ask the NodeList for the current values for connection times
QMap<NodeList::ConnectionStep, quint64> times = DependencyManager::get<NodeList>()->getLastConnectionTimes();
// setup our data with the returned values
quint64 totalTime = 0;
quint64 firstStepTime = times[NodeList::ConnectionStep::LookupAddress] / USECS_PER_MSEC;
quint64 lastStepTime = firstStepTime;
const QMetaObject &nodeListMeta = NodeList::staticMetaObject;
QMetaEnum stepEnum = nodeListMeta.enumerator(nodeListMeta.indexOfEnumerator("ConnectionStep"));
for (int i = 0; i < stepEnum.keyCount(); i++) {
NodeList::ConnectionStep step = static_cast<NodeList::ConnectionStep>(i);
if (times.contains(step)) {
// When did this step occur, how long since the last step, how long since the start?
_timestamps[_numRows] = times[step] / USECS_PER_MSEC;
_deltas[_numRows] = (_timestamps[_numRows] - lastStepTime);
_totals[_numRows] = _timestamps[_numRows] - firstStepTime;
// increment the total time by this delta to keep track
totalTime += _deltas[_numRows];
lastStepTime = _timestamps[_numRows];
// increment our counted number of rows
++_numRows;
}
}
}
QVariant DomainConnectionTableModel::headerData(int section, Qt::Orientation orientation, int role) const {
switch(section) {
case 0:
return QVariant("Name");
case 1:
return QVariant("Timestamp (ms)");
case 2:
return QVariant("Delta (ms)");
case 3:
return QVariant("Total Elapsed (ms)");
default:
return QVariant();
}
}
QVariant DomainConnectionTableModel::data(const QModelIndex& index, int role) const {
switch(index.column()) {
case 0:
return _names[index.row()];
case 1:
return QVariant(_timestamps[index.row()]);
case 2:
return QVariant(_deltas[index.row()]);
case 3:
return QVariant(_totals[index.row()]);
default:
return QVariant();
}
}

View file

@ -1,41 +0,0 @@
//
// DomainConnectionTableModel.h
// interface/src/ui
//
// Created by Stephen Birarda on 05/26/15.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_DomainConnectionTableModel_h
#define hifi_DomainConnectionTableModel_h
#pragma once
#include <QtCore/QAbstractTableModel>
class DomainConnectionTableModel: public QAbstractTableModel {
Q_OBJECT
public:
DomainConnectionTableModel(QObject* parent = 0);
const int NUM_COLUMNS = 4; // name, time, delta, since start
int rowCount(const QModelIndex& parent = QModelIndex()) const { return _numRows; }
int columnCount(const QModelIndex& parent = QModelIndex()) const { return NUM_COLUMNS; }
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
private:
int _numRows = 0;
QVariantList _names;
QList<quint64> _timestamps;
QList<quint64> _deltas;
QList<quint64> _totals;
};
#endif // hifi_DomainConnectionTableModel_h