Enable the sorting of performance measurement values

This commit is contained in:
Alexander Bock
2016-06-05 23:27:24 +02:00
parent 6a4362d6ed
commit 6a2624dbb2
4 changed files with 120 additions and 31 deletions
@@ -315,7 +315,7 @@ void RenderablePlanetProjection::render(const RenderData& data) {
_programObject->setUniform("_heightExaggeration", _heightExaggeration);
_programObject->setUniform("_projectionFading", _projectionFading);
_programObject->setUniform("debug_projectionTextureRotation", glm::radians(_debugProjectionTextureRotation.value()));
//_programObject->setUniform("debug_projectionTextureRotation", glm::radians(_debugProjectionTextureRotation.value()));
setPscUniforms(*_programObject.get(), data.camera, data.position);
@@ -1,26 +1,26 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/engine/configurationmanager.h>
#include <modules/newhorizons/rendering/renderableshadowcylinder.h>
@@ -80,8 +80,7 @@ namespace openspace {
ghoul_assert(success, "");
}
RenderableShadowCylinder::~RenderableShadowCylinder() {
}
RenderableShadowCylinder::~RenderableShadowCylinder() {}
bool RenderableShadowCylinder::isReady() const {
bool ready = true;
@@ -103,6 +102,8 @@ bool RenderableShadowCylinder::initialize() {
if (!_shader)
return false;
return completeSuccess;
}
@@ -44,6 +44,7 @@ public:
protected:
ghoul::SharedMemory* _performanceMemory = nullptr;
float _minMaxValues[2];
int _sortingSelection;
};
} // namespace gui
@@ -27,8 +27,12 @@
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
#include <ghoul/misc/sharedmemory.h>
#include <imgui.h>
#include <cppformat/format.h>
#include <algorithm>
#include <numeric>
namespace {
const std::string _loggerCat = "GuiPerformanceComponent";
@@ -40,6 +44,7 @@ namespace gui {
void GuiPerformanceComponent::initialize() {
_minMaxValues[0] = 100.f;
_minMaxValues[1] = 250.f;
_sortingSelection = -1;
}
void GuiPerformanceComponent::deinitialize() {
@@ -82,26 +87,108 @@ void GuiPerformanceComponent::render() {
ImGui::SliderFloat2("Min values, max Value", _minMaxValues, 0.f, 10000.f);
_minMaxValues[1] = fmaxf(_minMaxValues[0], _minMaxValues[1]);
// The indices correspond to the index into the average array further below
ImGui::Text("Sorting");
ImGui::RadioButton("No Sorting", &_sortingSelection, -1);
ImGui::RadioButton("UpdateEphemeris", &_sortingSelection, 0);
ImGui::RadioButton("UpdateRender", &_sortingSelection, 1);
ImGui::RadioButton("RenderTime", &_sortingSelection, 2);
if (!_performanceMemory)
_performanceMemory = new ghoul::SharedMemory(RenderEngine::PerformanceMeasurementSharedData);
void* ptr = _performanceMemory->memory();
PerformanceLayout* layout = reinterpret_cast<PerformanceLayout*>(ptr);
for (int i = 0; i < layout->nEntries; ++i) {
const PerformanceLayout::PerformanceLayoutEntry& entry = layout->entries[i];
PerformanceLayout layout = *reinterpret_cast<PerformanceLayout*>(ptr);
std::vector<size_t> indices(layout.nEntries);
std::iota(indices.begin(), indices.end(), 0);
// Ordering:
// updateEphemeris
// UpdateRender
// RenderTime
std::vector<std::array<float, 3>> averages(layout.nEntries, { 0.f, 0.f, 0.f });
for (int i = 0; i < layout.nEntries; ++i) {
const PerformanceLayout::PerformanceLayoutEntry& entry = layout.entries[i];
int v[3] = { 0, 0, 0 };
for (int j = 0; j < nValues; ++j) {
averages[i][0] += entry.updateEphemeris[j];
if (entry.updateEphemeris[j] != 0.f)
++v[0];
averages[i][1] += entry.updateRenderable[j];
if (entry.updateRenderable[j] != 0.f)
++v[1];
averages[i][2] += entry.renderTime[j];
if (entry.renderTime[j] != 0.f)
++v[2];
}
if (v[0] != 0)
averages[i][0] /= static_cast<float>(v[0]);
if (v[1] != 0)
averages[i][1] /= static_cast<float>(v[1]);
if (v[2] != 0)
averages[i][2] /= static_cast<float>(v[2]);
}
if (_sortingSelection != -1) {
int sortIndex = _sortingSelection;
std::sort(
indices.begin(),
indices.end(),
[sortIndex, &averages](int a, int b) {
return averages[a][sortIndex] > averages[b][sortIndex];
}
);
}
for (int i = 0; i < layout.nEntries; ++i) {
const PerformanceLayout::PerformanceLayoutEntry& entry = layout.entries[indices[i]];
if (ImGui::CollapsingHeader(entry.name)) {
std::string updateEphemerisTime = std::to_string(entry.updateEphemeris[entry.currentUpdateEphemeris - 1]) + "us";
ImGui::PlotLines("UpdateEphemeris", &entry.updateEphemeris[0], layout->nValuesPerEntry, 0, updateEphemerisTime.c_str(), _minMaxValues[0], _minMaxValues[1], ImVec2(0, 40));
;
ImGui::PlotLines(
fmt::format("UpdateEphemeris\nAverage: {}us", averages[i][0]).c_str(),
&entry.updateEphemeris[0],
layout.nValuesPerEntry,
0,
updateEphemerisTime.c_str(),
_minMaxValues[0],
_minMaxValues[1],
ImVec2(0, 40)
);
std::string updateRenderableTime = std::to_string(entry.updateRenderable[entry.currentUpdateRenderable - 1]) + "us";
ImGui::PlotLines("UpdateRender", &entry.updateRenderable[0], layout->nValuesPerEntry, 0, updateRenderableTime.c_str(), _minMaxValues[0], _minMaxValues[1], ImVec2(0, 40));
ImGui::PlotLines(
fmt::format("UpdateRender\nAverage: {}us", averages[i][1]).c_str(),
&entry.updateRenderable[0],
layout.nValuesPerEntry,
0,
updateRenderableTime.c_str(),
_minMaxValues[0],
_minMaxValues[1],
ImVec2(0, 40)
);
std::string renderTime = std::to_string(entry.renderTime[entry.currentRenderTime - 1]) + "us";
ImGui::PlotLines("RenderTime", &entry.renderTime[0], layout->nValuesPerEntry, 0, renderTime.c_str(), _minMaxValues[0], _minMaxValues[1], ImVec2(0, 40));
ImGui::PlotLines(
fmt::format("RenderTime\nAverage: {}us", averages[i][2]).c_str(),
&entry.renderTime[0],
layout.nValuesPerEntry,
0,
renderTime.c_str(),
_minMaxValues[0],
_minMaxValues[1],
ImVec2(0, 40)
);
}
}
}