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 <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
diff --git a/src/tests/perf_tests/DawnPerfTest.cpp b/src/tests/perf_tests/DawnPerfTest.cpp
index 20068ee..8a508df 100644
--- a/src/tests/perf_tests/DawnPerfTest.cpp
+++ b/src/tests/perf_tests/DawnPerfTest.cpp
@@ -237,6 +237,7 @@
dawn_platform::Platform* platform = gTestEnv->GetInstance()->GetPlatform();
mNumStepsPerformed = 0;
+ cpuTime = 0;
mRunning = true;
wgpu::FenceDescriptor desc = {};
@@ -252,7 +253,10 @@
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 @@
}
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 b1f4ba1..f6859d1 100644
--- a/src/tests/perf_tests/DawnPerfTest.h
+++ b/src/tests/perf_tests/DawnPerfTest.h
@@ -97,6 +97,7 @@
const unsigned int mMaxStepsInFlight;
unsigned int mStepsToRun = 0;
unsigned int mNumStepsPerformed = 0;
+ double cpuTime;
std::unique_ptr<utils::Timer> mTimer;
};