From c3167444a9d28f7007993edaf469254173fb4389 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 2 Oct 2017 16:31:20 -0700 Subject: [PATCH] decouple 'general timing' from 'game loop' details --- interface/src/ui/Stats.cpp | 31 +++++++++++++++++++------------ interface/src/ui/Stats.h | 5 +++-- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index 358b877840..70cb74ed2f 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -117,10 +117,9 @@ void Stats::updateStats(bool force) { } } - bool shouldDisplayTimingDetail = Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails) && - Menu::getInstance()->isOptionChecked(MenuOption::Stats) && isExpanded(); - if (shouldDisplayTimingDetail != PerformanceTimer::isActive()) { - PerformanceTimer::setActive(shouldDisplayTimingDetail); + bool performanceTimerShouldBeActive = Menu::getInstance()->isOptionChecked(MenuOption::Stats) && _expanded; + if (performanceTimerShouldBeActive != PerformanceTimer::isActive()) { + PerformanceTimer::setActive(performanceTimerShouldBeActive); } auto nodeList = DependencyManager::get(); @@ -406,10 +405,11 @@ void Stats::updateStats(bool force) { } bool performanceTimerIsActive = PerformanceTimer::isActive(); - bool displayPerf = _expanded && Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails); - if (displayPerf && performanceTimerIsActive) { - if (!_timingExpanded) { - _timingExpanded = true; + + if (performanceTimerShouldBeActive && + Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails)) { + if (!_showTimingDetails) { + _showTimingDetails = true; emit timingExpandedChanged(); } PerformanceTimer::tallyAllTimerRecords(); // do this even if we're not displaying them, so they don't stack up @@ -452,8 +452,15 @@ void Stats::updateStats(bool force) { } _timingStats = perfLines; emit timingStatsChanged(); + } else if (_showTimingDetails) { + _showTimingDetails = false; + emit timingExpandedChanged(); + } - // build _gameUpdateStats + if (_expanded && performanceTimerIsActive) { + if (!_showGameUpdateStats) { + _showGameUpdateStats = true; + } class SortableStat { public: SortableStat(QString a, float p) : message(a), priority(p) {} @@ -462,6 +469,7 @@ void Stats::updateStats(bool force) { bool operator<(const SortableStat& other) const { return priority < other.priority; } }; + const QMap& allRecords = PerformanceTimer::getAllTimerRecords(); std::priority_queue idleUpdateStats; auto itr = allRecords.find("/idle/update"); if (itr != allRecords.end()) { @@ -488,9 +496,8 @@ void Stats::updateStats(bool force) { _gameUpdateStats = ""; emit gameUpdateStatsChanged(); } - } else if (_timingExpanded) { - _timingExpanded = false; - emit timingExpandedChanged(); + } else if (_showGameUpdateStats) { + _showGameUpdateStats = false; _gameUpdateStats = ""; emit gameUpdateStatsChanged(); } diff --git a/interface/src/ui/Stats.h b/interface/src/ui/Stats.h index 0b10e7fdfe..af3189f20b 100644 --- a/interface/src/ui/Stats.h +++ b/interface/src/ui/Stats.h @@ -146,7 +146,7 @@ public: void updateStats(bool force = false); bool isExpanded() { return _expanded; } - bool isTimingExpanded() { return _timingExpanded; } + bool isTimingExpanded() { return _showTimingDetails; } void setExpanded(bool expanded) { if (_expanded != expanded) { @@ -264,7 +264,8 @@ private: int _recentMaxPackets{ 0 } ; // recent max incoming voxel packets to process bool _resetRecentMaxPacketsSoon{ true }; bool _expanded{ false }; - bool _timingExpanded{ false }; + bool _showTimingDetails{ false }; + bool _showGameUpdateStats{ false }; QString _monospaceFont; const AudioIOStats* _audioStats; QStringList _downloadUrls = QStringList();