Skip to content

Commit

Permalink
Benchmark: Shows min, max and average submission time on CPU (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
elviscapiaq authored Nov 17, 2023
1 parent f350c7a commit d0815b8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
31 changes: 31 additions & 0 deletions benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "SphereMesh.h"

#include "ppx/graphics_util.h"
#include "ppx/timer.h"

using namespace ppx;

Expand Down Expand Up @@ -885,7 +886,21 @@ void GraphicsBenchmarkApp::Render()
}
submitInfo.pFence = frame.renderCompleteFence;

Timer timerSubmit;
PPX_ASSERT_MSG(timerSubmit.Start() == TIMER_RESULT_SUCCESS, "Error starting the Timer");
PPX_CHECKED_CALL(GetGraphicsQueue()->Submit(&submitInfo));
double t = timerSubmit.MillisSinceStart();

uint64_t frameCount = GetFrameCount();
mSubmissionTime.average = (mSubmissionTime.average * frameCount + t) / (frameCount + 1);
if (frameCount == 0) {
mSubmissionTime.min = t;
mSubmissionTime.max = t;
}
else {
mSubmissionTime.min = std::min(mSubmissionTime.min, t);
mSubmissionTime.max = std::max(mSubmissionTime.max, t);
}

#if defined(PPX_BUILD_XR)
// No need to present when XR is enabled.
Expand Down Expand Up @@ -937,6 +952,22 @@ void GraphicsBenchmarkApp::DrawExtraInfo()
uint64_t frequency = 0;
GetGraphicsQueue()->GetTimestampFrequency(&frequency);

ImGui::Columns(2);
ImGui::Text("CPU Average Submission Time");
ImGui::NextColumn();
ImGui::Text("%.2f ms ", mSubmissionTime.average);
ImGui::NextColumn();

ImGui::Text("CPU Min Submission Time");
ImGui::NextColumn();
ImGui::Text("%.2f ms ", mSubmissionTime.min);
ImGui::NextColumn();

ImGui::Text("CPU Max Submission Time");
ImGui::NextColumn();
ImGui::Text("%.2f ms ", mSubmissionTime.max);
ImGui::NextColumn();

ImGui::Columns(2);
const float gpuWorkDurationInSec = static_cast<float>(mGpuWorkDuration / static_cast<double>(frequency));
const float gpuWorkDurationInMs = gpuWorkDurationInSec * 1000.0f;
Expand Down
8 changes: 8 additions & 0 deletions benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ class GraphicsBenchmarkApp
};
};

struct SubmissionTime
{
double min;
double max;
double average;
};

private:
using SpherePipelineMap = std::unordered_map<SpherePipelineKey, grfx::GraphicsPipelinePtr, SpherePipelineKey::Hash>;

Expand All @@ -218,6 +225,7 @@ class GraphicsBenchmarkApp
uint64_t mGpuWorkDuration;
grfx::SamplerPtr mLinearSampler;
grfx::DescriptorPoolPtr mDescriptorPool;
SubmissionTime mSubmissionTime;

// SkyBox resources
Entity mSkyBox;
Expand Down

0 comments on commit d0815b8

Please sign in to comment.