diff --git a/libraries/gl/src/gl/OffscreenQmlSurface.cpp b/libraries/gl/src/gl/OffscreenQmlSurface.cpp index 4ab19744d4..3a803172d0 100644 --- a/libraries/gl/src/gl/OffscreenQmlSurface.cpp +++ b/libraries/gl/src/gl/OffscreenQmlSurface.cpp @@ -103,11 +103,14 @@ public: } void report() { - uint64_t now = usecTimestampNow(); - if ((now - _lastReport) > USECS_PER_SECOND * 5) { - _lastReport = now; - qCDebug(glLogging) << "Current offscreen texture count " << _allTextureCount; - qCDebug(glLogging) << "Current offscreen active texture count " << _activeTextureCount; + if (randFloat() < 0.01f) { + PROFILE_COUNTER(render_qml_gl, "offscreenTextures", { + { "total", QVariant::fromValue(_allTextureCount.load()) }, + { "active", QVariant::fromValue(_activeTextureCount.load()) }, + }); + PROFILE_COUNTER(render_qml_gl, "offscreenTextureMemory", { + { "value", QVariant::fromValue(_totalTextureUsage) } + }); } } @@ -189,7 +192,6 @@ private: std::unordered_map _textureSizes; Mutex _mutex; std::list _returnedTextures; - uint64_t _lastReport { 0 }; size_t _totalTextureUsage { 0 }; } offscreenTextures; diff --git a/libraries/shared/src/StatTracker.cpp b/libraries/shared/src/StatTracker.cpp index 4ec4e31797..0ac9ab0092 100644 --- a/libraries/shared/src/StatTracker.cpp +++ b/libraries/shared/src/StatTracker.cpp @@ -12,23 +12,30 @@ StatTracker::StatTracker() { } -QVariant StatTracker::getStat(QString name) { +QVariant StatTracker::getStat(const QString& name) { std::lock_guard lock(_statsLock); return _stats[name]; } -void StatTracker::editStat(QString name, EditStatFunction fn) { - std::lock_guard lock(_statsLock); - _stats[name] = fn(_stats[name]); +void StatTracker::setStat(const QString& name, int value) { + Lock lock(_statsLock); + _stats[name] = value; } -void StatTracker::incrementStat(QString name) { - std::lock_guard lock(_statsLock); - QVariant stat = _stats[name]; - _stats[name] = _stats[name].toInt() + 1; +void StatTracker::updateStat(const QString& name, int value) { + Lock lock(_statsLock); + auto itr = _stats.find(name); + if (_stats.end() == itr) { + _stats[name] = value; + } else { + *itr = *itr + value; + } } -void StatTracker::decrementStat(QString name) { - std::lock_guard lock(_statsLock); - _stats[name] = _stats[name].toInt() - 1; +void StatTracker::incrementStat(const QString& name) { + updateStat(name, 1); +} + +void StatTracker::decrementStat(const QString& name) { + updateStat(name, -1); } \ No newline at end of file diff --git a/libraries/shared/src/StatTracker.h b/libraries/shared/src/StatTracker.h index b500d9a821..38afc2c379 100644 --- a/libraries/shared/src/StatTracker.h +++ b/libraries/shared/src/StatTracker.h @@ -8,10 +8,13 @@ #pragma once -#include -#include -#include +#include +#include +#include +#include + #include + #include "DependencyManager.h" #include "Trace.h" @@ -20,13 +23,16 @@ using EditStatFunction = std::function; class StatTracker : public Dependency { public: StatTracker(); - QVariant getStat(QString name); - void editStat(QString name, EditStatFunction fn); - void incrementStat(QString name); - void decrementStat(QString name); + QVariant getStat(const QString& name); + void setStat(const QString& name, int value); + void updateStat(const QString& name, int mod); + void incrementStat(const QString& name); + void decrementStat(const QString& name); private: - std::mutex _statsLock; - QVariantMap _stats; + using Mutex = std::mutex; + using Lock = std::lock_guard; + Mutex _statsLock; + QHash _stats; }; class CounterStat { diff --git a/scripts/developer/tests/testTestMode.js b/scripts/developer/tests/testTestMode.js deleted file mode 100644 index b535f635e4..0000000000 --- a/scripts/developer/tests/testTestMode.js +++ /dev/null @@ -1,25 +0,0 @@ -// -// Created by Bradley Austin Davis on 2016/12/12 -// Copyright 2013-2016 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 -// - - -Script.setTimeout(function() { - var loggingRules = "" + -"*.debug=false\n" + -"hifi.render.debug=true\n" + -"hifi.interface.debug=true\n" + -""; - Test.startTracing(loggingRules); -}, 1 * 1000); - - -Script.setTimeout(function() { - Test.stopTracing("h:/testScriptTrace.json.gz"); - Test.quit(); -}, 10 * 1000); - -