mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-14 05:26:32 +02:00
Merge pull request #7708 from zzmp/feat/render-rates
Add renderRates.js to visualize rates over time
This commit is contained in:
commit
d87d631871
5 changed files with 115 additions and 1 deletions
49
examples/utilities/render/rates.qml
Normal file
49
examples/utilities/render/rates.qml
Normal file
|
@ -0,0 +1,49 @@
|
|||
//
|
||||
// stats.qml
|
||||
// examples/utilities/cache
|
||||
//
|
||||
// Created by Zach Pomerantz on 4/1/2016
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
import "../lib/plotperf"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
anchors.fill: parent
|
||||
|
||||
property var caches: [ ["Present", "present"], ["Present", "present"], ["New", "newFrame"], ["Dropped", "dropped"], ["Simulation", "simulation"], ["Avatar", "avatar"] ]
|
||||
property var colors: [ "#1AC567", "#00B4EF" ]
|
||||
|
||||
Grid {
|
||||
id: grid
|
||||
rows: (root.caches.length / 2); columns: 2; spacing: 8
|
||||
anchors.fill: parent
|
||||
|
||||
Repeater {
|
||||
id: repeater
|
||||
|
||||
model: root.caches
|
||||
|
||||
Row {
|
||||
PlotPerf {
|
||||
title: modelData[0] + " Rate"
|
||||
height: (grid.height - (grid.spacing * ((root.caches.length / 2) + 1))) / (root.caches.length / 2)
|
||||
width: grid.width / 2 - grid.spacing * 1.5
|
||||
object: Rates
|
||||
valueScale: 1
|
||||
valueUnit: "fps"
|
||||
valueNumDigits: "2"
|
||||
plots: [{
|
||||
prop: modelData[1],
|
||||
color: root.colors[index % 2]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
21
examples/utilities/render/renderRates.js
Normal file
21
examples/utilities/render/renderRates.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// cacheStats.js
|
||||
// examples/utilities/cache
|
||||
//
|
||||
// Zach Pomerantz, created on 4/1/2016.
|
||||
// Copyright 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
|
||||
//
|
||||
|
||||
// Set up the qml ui
|
||||
var qml = Script.resolvePath('rates.qml');
|
||||
var window = new OverlayWindow({
|
||||
title: 'Render Rates',
|
||||
source: qml,
|
||||
width: 300,
|
||||
height: 200
|
||||
});
|
||||
window.setPosition(500, 50);
|
||||
window.closed.connect(function() { Script.stop(); });
|
|
@ -131,6 +131,7 @@
|
|||
#include "scripting/WebWindowClass.h"
|
||||
#include "scripting/WindowScriptingInterface.h"
|
||||
#include "scripting/ControllerScriptingInterface.h"
|
||||
#include "scripting/RatesScriptingInterface.h"
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
#include "SpeechRecognizer.h"
|
||||
#endif
|
||||
|
@ -1384,6 +1385,7 @@ void Application::initializeUi() {
|
|||
rootContext->setContextProperty("Preferences", DependencyManager::get<Preferences>().data());
|
||||
rootContext->setContextProperty("AddressManager", DependencyManager::get<AddressManager>().data());
|
||||
rootContext->setContextProperty("FrameTimings", &_frameTimingsScriptingInterface);
|
||||
rootContext->setContextProperty("Rates", new RatesScriptingInterface(this));
|
||||
|
||||
rootContext->setContextProperty("TREE_SCALE", TREE_SCALE);
|
||||
rootContext->setContextProperty("Quat", new Quat());
|
||||
|
@ -4439,6 +4441,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
// AvatarManager has some custom types
|
||||
AvatarManager::registerMetaTypes(scriptEngine);
|
||||
|
||||
scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this));
|
||||
|
||||
// hook our avatar and avatar hash map object into this script engine
|
||||
scriptEngine->registerGlobalObject("MyAvatar", getMyAvatar());
|
||||
qScriptRegisterMetaType(scriptEngine, audioListenModeToScriptValue, audioListenModeFromScriptValue);
|
||||
|
|
37
interface/src/scripting/RatesScriptingInterface.h
Normal file
37
interface/src/scripting/RatesScriptingInterface.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
//
|
||||
// RatesScriptingInterface.h
|
||||
// interface/src/scripting
|
||||
//
|
||||
// Created by Zach Pomerantz on 4/20/16.
|
||||
// Copyright 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
|
||||
//
|
||||
|
||||
#ifndef HIFI_RATES_SCRIPTING_INTERFACE_H
|
||||
#define HIFI_RATES_SCRIPTING_INTERFACE_H
|
||||
|
||||
#include <display-plugins/DisplayPlugin.h>
|
||||
|
||||
class RatesScriptingInterface : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(float render READ getRenderRate)
|
||||
Q_PROPERTY(float present READ getPresentRate)
|
||||
Q_PROPERTY(float newFrame READ getNewFrameRate)
|
||||
Q_PROPERTY(float dropped READ getDropRate)
|
||||
Q_PROPERTY(float simulation READ getSimulationRate)
|
||||
Q_PROPERTY(float avatar READ getAvatarRate)
|
||||
|
||||
public:
|
||||
RatesScriptingInterface(QObject* parent) : QObject(parent) {}
|
||||
float getRenderRate() { return qApp->getFps(); }
|
||||
float getPresentRate() { return qApp->getActiveDisplayPlugin()->presentRate(); }
|
||||
float getNewFrameRate() { return qApp->getActiveDisplayPlugin()->newFramePresentRate(); }
|
||||
float getDropRate() { return qApp->getActiveDisplayPlugin()->droppedFrameRate(); }
|
||||
float getSimulationRate() { return qApp->getAverageSimsPerSecond(); }
|
||||
float getAvatarRate() { return qApp->getAvatarSimrate(); }
|
||||
};
|
||||
|
||||
#endif // HIFI_INTERFACE_RATES_SCRIPTING_INTERFACE_H
|
|
@ -11,6 +11,7 @@
|
|||
#define hifi_Shared_RateCounter_h
|
||||
|
||||
#include <stdint.h>
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <QtCore/QElapsedTimer>
|
||||
|
||||
|
@ -20,6 +21,8 @@
|
|||
template <uint32_t INTERVAL = MSECS_PER_SECOND, uint8_t PRECISION = 2>
|
||||
class RateCounter {
|
||||
public:
|
||||
RateCounter() { _rate = 0; } // avoid use of std::atomic copy ctor
|
||||
|
||||
void increment(size_t count = 1) {
|
||||
auto now = usecTimestampNow();
|
||||
float currentIntervalMs = (now - _start) / (float) USECS_PER_MSEC;
|
||||
|
@ -42,8 +45,8 @@ public:
|
|||
private:
|
||||
uint64_t _start { usecTimestampNow() };
|
||||
size_t _count { 0 };
|
||||
float _rate { 0 };
|
||||
const float _scale { powf(10, PRECISION) };
|
||||
std::atomic<float> _rate;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue