aboutsummaryrefslogtreecommitdiff
path: root/BuddhaTest/src/BuddhaTest.cpp
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2018-03-21 23:16:20 +0100
committerAndreas Grois <andi@grois.info>2018-03-21 23:16:20 +0100
commitcca3254becdf793b9335a1f21bcda2c0909f4d1a (patch)
tree9f6f38f57774cf08e6968052a1c77dd2941dc194 /BuddhaTest/src/BuddhaTest.cpp
parent0c7b45b4e84aa197ada7391007f7d1610c92476c (diff)
Initial benchmark support.
Finally no more manual stopwatch usage...
Diffstat (limited to 'BuddhaTest/src/BuddhaTest.cpp')
-rw-r--r--BuddhaTest/src/BuddhaTest.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/BuddhaTest/src/BuddhaTest.cpp b/BuddhaTest/src/BuddhaTest.cpp
index 55fe2c2..0ae94b0 100644
--- a/BuddhaTest/src/BuddhaTest.cpp
+++ b/BuddhaTest/src/BuddhaTest.cpp
@@ -169,8 +169,10 @@ int main(int argc, char * argv[])
uint64_t totalIterationCount{0};
uint64_t lastMessage{0};
+ const auto startTime{std::chrono::high_resolution_clock::now()};
+ auto frameStop{startTime};
/* Loop until the user closes the window */
- while (!glfwWindowShouldClose(window))
+ while (!glfwWindowShouldClose(window) && (settings.benchmarkTime == 0 || std::chrono::duration_cast<std::chrono::seconds>(frameStop-startTime).count() < settings.benchmarkTime))
{
auto frameStart{std::chrono::high_resolution_clock::now()};
totalIterationCount += iterationsPerFrame;
@@ -205,7 +207,7 @@ int main(int argc, char * argv[])
/* Poll for and process events */
glfwPollEvents();
- auto frameStop{std::chrono::high_resolution_clock::now()};
+ frameStop = std::chrono::high_resolution_clock::now();
const auto dur{std::chrono::duration_cast<std::chrono::microseconds>(frameStop-frameStart)};
auto frameDuration{dur.count()};
if(frameDuration > 0)
@@ -227,14 +229,18 @@ int main(int argc, char * argv[])
}
//settings.pngFilename = "Don'tForgetToRemoveThisLine.png";
- if(!settings.pngFilename.empty())
+ if(!settings.pngFilename.empty() || settings.benchmarkTime != 0)
{
glMemoryBarrier(GL_ALL_BARRIER_BITS);
std::vector<uint32_t> readBackBuffer(pixelCount*3);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, drawBuffer);
glGetBufferSubData(GL_SHADER_STORAGE_BUFFER,0,4 *3* pixelCount,readBackBuffer.data());
- Helpers::WriteOutputPNG(settings.pngFilename,readBackBuffer,settings.imageWidth,bufferHeight, settings.pngGamma, settings.pngColorScale);
+ if(settings.benchmarkTime != 0)
+ Helpers::PrintBenchmarkScore(readBackBuffer);
+
+ if(!settings.pngFilename.empty())
+ Helpers::WriteOutputPNG(settings.pngFilename,readBackBuffer,settings.imageWidth,bufferHeight, settings.pngGamma, settings.pngColorScale);
}
//a bit of cleanup