Add totalTime tracking in performanceMeasurements

This commit is contained in:
Matthew Territo
2017-07-19 17:29:21 -06:00
parent e810dcf5b2
commit 8935c9381f
4 changed files with 54 additions and 10 deletions

View File

@@ -84,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);

View File

@@ -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();

View File

@@ -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,9 +396,6 @@ 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)),
@@ -432,6 +430,15 @@ void PerformanceManager::storeScenePerformanceMeasurements(
std::end(entry.updateRenderable)
);
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();

View File

@@ -374,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(