From a930e599e17c14e0a72fe7403aab69d791885da8 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Fri, 15 Nov 2019 15:43:26 +0000 Subject: [PATCH] Add cpu_time metric to dawn_perf_tests The cpu_time metric measures the amount of CPU time spent on a step. It excludes time spent waiting for the GPU or time between frames. Bug: dawn:208 Change-Id: I5624d45557716c02bb7da632d2347eca0b81ad41 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13640 Reviewed-by: Corentin Wallez Reviewed-by: Kai Ninomiya Commit-Queue: Austin Eng --- src/tests/perf_tests/DawnPerfTest.cpp | 5 +++++ src/tests/perf_tests/DawnPerfTest.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/tests/perf_tests/DawnPerfTest.cpp b/src/tests/perf_tests/DawnPerfTest.cpp index 20068ee947..8a508df7ab 100644 --- a/src/tests/perf_tests/DawnPerfTest.cpp +++ b/src/tests/perf_tests/DawnPerfTest.cpp @@ -237,6 +237,7 @@ void DawnPerfTestBase::DoRunLoop(double maxRunTime) { dawn_platform::Platform* platform = gTestEnv->GetInstance()->GetPlatform(); mNumStepsPerformed = 0; + cpuTime = 0; mRunning = true; wgpu::FenceDescriptor desc = {}; @@ -252,7 +253,10 @@ void DawnPerfTestBase::DoRunLoop(double maxRunTime) { mTest->WaitABit(); } TRACE_EVENT0(platform, General, "Step"); + double stepStart = mTimer->GetElapsedTime(); Step(); + cpuTime += mTimer->GetElapsedTime() - stepStart; + mTest->queue.Signal(fence, ++signaledFenceValue); if (mRunning) { @@ -339,6 +343,7 @@ void DawnPerfTestBase::OutputResults() { } PrintPerIterationResultFromSeconds("wall_time", mTimer->GetElapsedTime(), true); + PrintPerIterationResultFromSeconds("cpu_time", cpuTime, true); PrintPerIterationResultFromSeconds("validation_time", totalValidationTime, true); PrintPerIterationResultFromSeconds("recording_time", totalRecordingTime, true); diff --git a/src/tests/perf_tests/DawnPerfTest.h b/src/tests/perf_tests/DawnPerfTest.h index b1f4ba1ebc..f6859d138d 100644 --- a/src/tests/perf_tests/DawnPerfTest.h +++ b/src/tests/perf_tests/DawnPerfTest.h @@ -97,6 +97,7 @@ class DawnPerfTestBase { const unsigned int mMaxStepsInFlight; unsigned int mStepsToRun = 0; unsigned int mNumStepsPerformed = 0; + double cpuTime; std::unique_ptr mTimer; };