mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-26 22:19:17 -06:00
Merge branch 'feature/statlogs' into feature/multiresvolume
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/*****************************************************************************************
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
@@ -45,6 +45,7 @@ struct PerformanceLayout {
|
||||
float updateTranslation[NumberValues];
|
||||
float updateRotation[NumberValues];
|
||||
float updateScaling[NumberValues];
|
||||
float totalTime[NumberValues];
|
||||
};
|
||||
SceneGraphPerformanceLayout sceneGraphEntries[MaxValues];
|
||||
int16_t nScaleGraphEntries;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*****************************************************************************************
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
|
||||
namespace ghoul { class Dictionary; }
|
||||
|
||||
@@ -57,11 +58,12 @@ public:
|
||||
using UpdateScene = ghoul::Boolean;
|
||||
|
||||
struct PerformanceRecord {
|
||||
long long renderTime; // time in ns
|
||||
long long updateTimeRenderable; // time in ns
|
||||
long long updateTimeTranslation; // time in ns
|
||||
long long updateTimeRotation; // time in ns
|
||||
long long updateTimeScaling; // time in ns
|
||||
std::chrono::nanoseconds renderTime;
|
||||
std::chrono::nanoseconds updateTimeRenderable;
|
||||
std::chrono::nanoseconds updateTimeTranslation;
|
||||
std::chrono::nanoseconds updateTimeRotation;
|
||||
std::chrono::nanoseconds updateTimeScaling;
|
||||
std::chrono::nanoseconds totalTime;
|
||||
};
|
||||
|
||||
static const std::string RootNodeName;
|
||||
@@ -82,6 +84,7 @@ public:
|
||||
void traversePostOrder(std::function<void(SceneGraphNode*)> fn);
|
||||
void update(const UpdateData& data);
|
||||
void render(const RenderData& data, RendererTasks& tasks);
|
||||
void clearPerformanceTotalTime();
|
||||
void updateCamera(Camera* camera) const;
|
||||
|
||||
void attachChild(std::unique_ptr<SceneGraphNode> child, UpdateScene updateScene = UpdateScene::Yes);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*****************************************************************************************
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
@@ -152,12 +152,12 @@ void GuiPerformanceComponent::render() {
|
||||
// updateScaling
|
||||
// UpdateRender
|
||||
// RenderTime
|
||||
std::vector<std::array<float, 5>> averages(
|
||||
std::vector<std::array<float, 6>> averages(
|
||||
layout->nScaleGraphEntries,
|
||||
{ 0.f, 0.f, 0.f, 0.f, 0.f }
|
||||
{ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }
|
||||
);
|
||||
|
||||
std::vector<std::array<std::pair<float, float>, 5>> minMax(
|
||||
std::vector<std::array<std::pair<float, float>, 6>> minMax(
|
||||
layout->nScaleGraphEntries
|
||||
);
|
||||
|
||||
@@ -165,7 +165,7 @@ void GuiPerformanceComponent::render() {
|
||||
const PerformanceLayout::SceneGraphPerformanceLayout& entry =
|
||||
layout->sceneGraphEntries[i];
|
||||
|
||||
int nValues[5] = { 0, 0, 0, 0, 0 };
|
||||
int nValues[6] = { 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
// Compute the averages and count the number of values so we don't divide
|
||||
// by 0 later
|
||||
@@ -185,6 +185,9 @@ void GuiPerformanceComponent::render() {
|
||||
averages[i][4] += entry.renderTime[j];
|
||||
if (entry.renderTime[j] != 0.f)
|
||||
++(nValues[4]);
|
||||
averages[i][5] += entry.totalTime[j];
|
||||
if (entry.totalTime[j] != 0.f)
|
||||
++(nValues[5]);
|
||||
}
|
||||
|
||||
if (nValues[0] != 0) {
|
||||
@@ -202,6 +205,9 @@ void GuiPerformanceComponent::render() {
|
||||
if (nValues[4] != 0) {
|
||||
averages[i][4] /= static_cast<float>(nValues[4]);
|
||||
}
|
||||
if (nValues[5] != 0) {
|
||||
averages[i][5] /= static_cast<float>(nValues[5]);
|
||||
}
|
||||
|
||||
// Get the minimum/maximum values for each of the components so that we
|
||||
// can scale the plot by these numbers
|
||||
@@ -249,7 +255,15 @@ void GuiPerformanceComponent::render() {
|
||||
*(minmaxRendering.first),
|
||||
*(minmaxRendering.second)
|
||||
);
|
||||
|
||||
|
||||
auto minmaxTotal = std::minmax_element(
|
||||
std::begin(entry.totalTime),
|
||||
std::end(entry.totalTime)
|
||||
);
|
||||
minMax[i][5] = std::make_pair(
|
||||
*(minmaxTotal.first),
|
||||
*(minmaxTotal.second)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -401,6 +415,24 @@ void GuiPerformanceComponent::render() {
|
||||
minMax[indices[i]][4].second,
|
||||
ImVec2(0, 40)
|
||||
);
|
||||
|
||||
std::string totalTime = std::to_string(
|
||||
entry.totalTime[PerformanceLayout::NumberValues - 1]
|
||||
) + "us";
|
||||
|
||||
ImGui::PlotLines(
|
||||
fmt::format(
|
||||
"TotalTime\nAverage: {}us",
|
||||
averages[indices[i]][5]
|
||||
).c_str(),
|
||||
&entry.totalTime[0],
|
||||
PerformanceLayout::NumberValues,
|
||||
0,
|
||||
totalTime.c_str(),
|
||||
minMax[indices[i]][5].first,
|
||||
minMax[indices[i]][5].second,
|
||||
ImVec2(0, 40)
|
||||
);
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*****************************************************************************************
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
@@ -242,7 +242,8 @@ void PerformanceManager::outputLogs() {
|
||||
node.updateRenderable[i],
|
||||
node.updateRotation[i],
|
||||
node.updateScaling[i],
|
||||
node.updateTranslation[i]
|
||||
node.updateTranslation[i],
|
||||
node.totalTime[i]
|
||||
};
|
||||
writeData(out, data);
|
||||
}
|
||||
@@ -395,43 +396,49 @@ void PerformanceManager::storeScenePerformanceMeasurements(
|
||||
SceneGraphNode::PerformanceRecord r = node->performanceRecord();
|
||||
PerformanceLayout::SceneGraphPerformanceLayout& entry = layout->sceneGraphEntries[i];
|
||||
|
||||
// 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 / micro;
|
||||
entry.renderTime[PerformanceLayout::NumberValues - 1] = std::chrono::duration_cast<std::chrono::microseconds>(r.renderTime).count();
|
||||
|
||||
std::rotate(
|
||||
std::begin(entry.updateTranslation),
|
||||
std::next(std::begin(entry.updateTranslation)),
|
||||
std::end(entry.updateTranslation)
|
||||
);
|
||||
entry.updateTranslation[PerformanceLayout::NumberValues - 1] = r.updateTimeTranslation / micro;
|
||||
entry.updateTranslation[PerformanceLayout::NumberValues - 1] = std::chrono::duration_cast<std::chrono::microseconds>(r.updateTimeTranslation).count();
|
||||
|
||||
std::rotate(
|
||||
std::begin(entry.updateRotation),
|
||||
std::next(std::begin(entry.updateRotation)),
|
||||
std::end(entry.updateRotation)
|
||||
);
|
||||
entry.updateRotation[PerformanceLayout::NumberValues - 1] = r.updateTimeRotation / micro;
|
||||
entry.updateRotation[PerformanceLayout::NumberValues - 1] = std::chrono::duration_cast<std::chrono::microseconds>(r.updateTimeRotation).count();
|
||||
|
||||
std::rotate(
|
||||
std::begin(entry.updateScaling),
|
||||
std::next(std::begin(entry.updateScaling)),
|
||||
std::end(entry.updateScaling)
|
||||
);
|
||||
entry.updateScaling[PerformanceLayout::NumberValues - 1] = r.updateTimeScaling / micro;
|
||||
entry.updateScaling[PerformanceLayout::NumberValues - 1] = std::chrono::duration_cast<std::chrono::microseconds>(r.updateTimeScaling).count();
|
||||
|
||||
std::rotate(
|
||||
std::begin(entry.updateRenderable),
|
||||
std::next(std::begin(entry.updateRenderable)),
|
||||
std::end(entry.updateRenderable)
|
||||
);
|
||||
entry.updateRenderable[PerformanceLayout::NumberValues - 1] = r.updateTimeRenderable / micro;
|
||||
entry.updateRenderable[PerformanceLayout::NumberValues - 1] = std::chrono::duration_cast<std::chrono::microseconds>(r.updateTimeRenderable).count();
|
||||
|
||||
std::rotate(
|
||||
std::begin(entry.totalTime),
|
||||
std::next(std::begin(entry.totalTime)),
|
||||
std::end(entry.totalTime)
|
||||
);
|
||||
entry.totalTime[PerformanceLayout::NumberValues - 1] = std::chrono::duration_cast<std::chrono::microseconds>(r.totalTime).count();
|
||||
// Reset the total after we log it
|
||||
node->clearPerformanceTotalTime();
|
||||
}
|
||||
_performanceMemory->releaseLock();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*****************************************************************************************
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
@@ -169,7 +169,14 @@ SceneGraphNode::SceneGraphNode()
|
||||
: properties::PropertyOwner("")
|
||||
, _parent(nullptr)
|
||||
, _scene(nullptr)
|
||||
, _performanceRecord({0, 0, 0, 0, 0})
|
||||
, _performanceRecord({
|
||||
std::chrono::nanoseconds(0),
|
||||
std::chrono::nanoseconds(0),
|
||||
std::chrono::nanoseconds(0),
|
||||
std::chrono::nanoseconds(0),
|
||||
std::chrono::nanoseconds(0),
|
||||
std::chrono::nanoseconds(0)
|
||||
})
|
||||
, _renderable(nullptr)
|
||||
, _transform {
|
||||
std::make_unique<StaticTranslation>(),
|
||||
@@ -231,6 +238,11 @@ void SceneGraphNode::traversePostOrder(std::function<void(SceneGraphNode*)> fn)
|
||||
}
|
||||
|
||||
void SceneGraphNode::update(const UpdateData& data) {
|
||||
auto startUpdate = std::chrono::high_resolution_clock::now();
|
||||
auto endUpdate = startUpdate;
|
||||
if (data.doPerformanceMeasurement) {
|
||||
startUpdate = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
if (_transform.translation) {
|
||||
if (data.doPerformanceMeasurement) {
|
||||
glFinish();
|
||||
@@ -240,7 +252,7 @@ void SceneGraphNode::update(const UpdateData& data) {
|
||||
|
||||
glFinish();
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
_performanceRecord.updateTimeTranslation = (end - start).count();
|
||||
_performanceRecord.updateTimeTranslation = (end - start);
|
||||
}
|
||||
else {
|
||||
_transform.translation->update(data);
|
||||
@@ -256,7 +268,7 @@ void SceneGraphNode::update(const UpdateData& data) {
|
||||
|
||||
glFinish();
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
_performanceRecord.updateTimeRotation = (end - start).count();
|
||||
_performanceRecord.updateTimeRotation = (end - start);
|
||||
}
|
||||
else {
|
||||
_transform.rotation->update(data);
|
||||
@@ -272,7 +284,7 @@ void SceneGraphNode::update(const UpdateData& data) {
|
||||
|
||||
glFinish();
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
_performanceRecord.updateTimeScaling = (end - start).count();
|
||||
_performanceRecord.updateTimeScaling = (end - start);
|
||||
}
|
||||
else {
|
||||
_transform.scale->update(data);
|
||||
@@ -308,11 +320,16 @@ void SceneGraphNode::update(const UpdateData& data) {
|
||||
|
||||
glFinish();
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
_performanceRecord.updateTimeRenderable = (end - start).count();
|
||||
_performanceRecord.updateTimeRenderable = (end - start);
|
||||
}
|
||||
else
|
||||
_renderable->update(newUpdateData);
|
||||
}
|
||||
|
||||
if (data.doPerformanceMeasurement) {
|
||||
endUpdate = std::chrono::high_resolution_clock::now();
|
||||
_performanceRecord.totalTime += (endUpdate - startUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) {
|
||||
@@ -344,7 +361,8 @@ void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) {
|
||||
|
||||
glFinish();
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
_performanceRecord.renderTime = (end - start).count();
|
||||
_performanceRecord.renderTime = (end - start);
|
||||
_performanceRecord.totalTime += (end - start);
|
||||
}
|
||||
else
|
||||
_renderable->render(newData, tasks);
|
||||
@@ -356,6 +374,10 @@ void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) {
|
||||
// child->render(newData);
|
||||
}
|
||||
|
||||
void SceneGraphNode::clearPerformanceTotalTime() {
|
||||
_performanceRecord.totalTime = std::chrono::nanoseconds(0);
|
||||
}
|
||||
|
||||
void SceneGraphNode::setParent(SceneGraphNode& parent, UpdateScene updateScene) {
|
||||
ghoul_assert(_parent != nullptr, "Node must be attached to a parent");
|
||||
ghoul_assert(
|
||||
|
||||
Reference in New Issue
Block a user