mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 11:39:49 -06:00
Enable PerformanceManager logging with ImGui checkbox.
This commit is contained in:
@@ -59,14 +59,24 @@ public:
|
||||
void storeScenePerformanceMeasurements(const std::vector<SceneGraphNode*>& sceneNodes);
|
||||
|
||||
void outputLogs();
|
||||
PerformanceLayout* performanceData();
|
||||
void enableLogging();
|
||||
void disableLogging();
|
||||
void toggleLogging();
|
||||
void setLogging(bool enabled);
|
||||
bool loggingEnabled();
|
||||
|
||||
PerformanceLayout* performanceData();
|
||||
private:
|
||||
bool _doPerformanceMeasurements;
|
||||
bool _loggingEnabled;
|
||||
|
||||
std::map<std::string, size_t> individualPerformanceLocations;
|
||||
|
||||
std::unique_ptr<ghoul::SharedMemory> _performanceMemory;
|
||||
|
||||
size_t _tick;
|
||||
|
||||
void tick();
|
||||
};
|
||||
|
||||
} // namespace performance
|
||||
|
||||
@@ -81,17 +81,16 @@ void GuiPerformanceComponent::render() {
|
||||
v = _functionsIsEnabled;
|
||||
ImGui::Checkbox("Functions", &v);
|
||||
_functionsIsEnabled = v;
|
||||
|
||||
v = OsEng.renderEngine().performanceManager()->loggingEnabled();
|
||||
ImGui::Checkbox("Output Logs", &v);
|
||||
OsEng.renderEngine().performanceManager()->setLogging(v);
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
|
||||
if (ImGui::Button("Reset measurements")) {
|
||||
OsEng.renderEngine().performanceManager()->resetPerformanceMeasurements();
|
||||
}
|
||||
|
||||
if (ImGui::Button("Output Logs")) {
|
||||
OsEng.renderEngine().performanceManager()->outputLogs();
|
||||
}
|
||||
|
||||
if (_sceneGraphIsEnabled) {
|
||||
bool sge = _sceneGraphIsEnabled;
|
||||
ImGui::Begin("SceneGraph", &sge);
|
||||
|
||||
@@ -130,6 +130,8 @@ void PerformanceManager::destroyGlobalSharedMemory() {
|
||||
|
||||
PerformanceManager::PerformanceManager()
|
||||
: _performanceMemory(nullptr)
|
||||
, _tick(0)
|
||||
, _loggingEnabled(false)
|
||||
{
|
||||
using ghoul::SharedMemory;
|
||||
PerformanceManager::createGlobalSharedMemory();
|
||||
@@ -213,11 +215,34 @@ void PerformanceManager::outputLogs() {
|
||||
}
|
||||
}
|
||||
|
||||
void PerformanceManager::enableLogging() {
|
||||
setLogging(true);
|
||||
}
|
||||
|
||||
void PerformanceManager::disableLogging() {
|
||||
setLogging(false);
|
||||
}
|
||||
|
||||
void PerformanceManager::toggleLogging() {
|
||||
_loggingEnabled = !_loggingEnabled;
|
||||
}
|
||||
void PerformanceManager::setLogging(bool enabled) {
|
||||
_loggingEnabled = enabled;
|
||||
}
|
||||
|
||||
bool PerformanceManager::loggingEnabled() {
|
||||
return _loggingEnabled;
|
||||
}
|
||||
|
||||
PerformanceLayout* PerformanceManager::performanceData() {
|
||||
void* ptr = _performanceMemory->memory();
|
||||
return reinterpret_cast<PerformanceLayout*>(ptr);
|
||||
}
|
||||
|
||||
void PerformanceManager::tick() {
|
||||
_tick = (_tick + 1) % PerformanceLayout::NumberValues;
|
||||
}
|
||||
|
||||
void PerformanceManager::storeIndividualPerformanceMeasurement
|
||||
(std::string identifier, long long microseconds)
|
||||
{
|
||||
@@ -278,45 +303,49 @@ void PerformanceManager::storeScenePerformanceMeasurements(
|
||||
SceneGraphNode::PerformanceRecord r = node->performanceRecord();
|
||||
PerformanceLayout::SceneGraphPerformanceLayout& entry = layout->sceneGraphEntries[i];
|
||||
|
||||
// Covert milliseconds to seconds
|
||||
const float second = 1000.f;
|
||||
// Covert nano to microseconds
|
||||
const float micro = 1000.f;
|
||||
|
||||
std::rotate(
|
||||
std::begin(entry.renderTime),
|
||||
std::next(std::begin(entry.renderTime)),
|
||||
std::end(entry.renderTime)
|
||||
);
|
||||
entry.renderTime[PerformanceLayout::NumberValues - 1] = r.renderTime / second;
|
||||
entry.renderTime[PerformanceLayout::NumberValues - 1] = r.renderTime / micro;
|
||||
|
||||
std::rotate(
|
||||
std::begin(entry.updateTranslation),
|
||||
std::next(std::begin(entry.updateTranslation)),
|
||||
std::end(entry.updateTranslation)
|
||||
);
|
||||
entry.updateTranslation[PerformanceLayout::NumberValues - 1] = r.updateTimeTranslation / second;
|
||||
entry.updateTranslation[PerformanceLayout::NumberValues - 1] = r.updateTimeTranslation / micro;
|
||||
|
||||
std::rotate(
|
||||
std::begin(entry.updateRotation),
|
||||
std::next(std::begin(entry.updateRotation)),
|
||||
std::end(entry.updateRotation)
|
||||
);
|
||||
entry.updateRotation[PerformanceLayout::NumberValues - 1] = r.updateTimeRotation / second;
|
||||
entry.updateRotation[PerformanceLayout::NumberValues - 1] = r.updateTimeRotation / micro;
|
||||
|
||||
std::rotate(
|
||||
std::begin(entry.updateScaling),
|
||||
std::next(std::begin(entry.updateScaling)),
|
||||
std::end(entry.updateScaling)
|
||||
);
|
||||
entry.updateScaling[PerformanceLayout::NumberValues - 1] = r.updateTimeScaling / second;
|
||||
entry.updateScaling[PerformanceLayout::NumberValues - 1] = r.updateTimeScaling / micro;
|
||||
|
||||
std::rotate(
|
||||
std::begin(entry.updateRenderable),
|
||||
std::next(std::begin(entry.updateRenderable)),
|
||||
std::end(entry.updateRenderable)
|
||||
);
|
||||
entry.updateRenderable[PerformanceLayout::NumberValues - 1] = r.updateTimeRenderable / second;
|
||||
entry.updateRenderable[PerformanceLayout::NumberValues - 1] = r.updateTimeRenderable / micro;
|
||||
}
|
||||
_performanceMemory->releaseLock();
|
||||
|
||||
if (_loggingEnabled && _tick == PerformanceLayout::NumberValues - 1) outputLogs();
|
||||
|
||||
tick();
|
||||
}
|
||||
|
||||
} // namespace performance
|
||||
|
||||
Reference in New Issue
Block a user