From c5e06a5d9f0d7f2088ff2382e7821e6dac690087 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Fri, 1 Nov 2019 15:07:01 +0000 Subject: [PATCH] Fix result units in perf tests Timing results extracted from trace events are reported in seconds, not milliseconds. Bug: dawn:208 Change-Id: I004d1ee5bbd0aaba8cf5b201f95903e76af0c530 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13000 Reviewed-by: Kai Ninomiya Reviewed-by: Corentin Wallez Commit-Queue: Austin Eng --- src/tests/perf_tests/DawnPerfTest.cpp | 28 +++++++++++++-------------- src/tests/perf_tests/DawnPerfTest.h | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/tests/perf_tests/DawnPerfTest.cpp b/src/tests/perf_tests/DawnPerfTest.cpp index 279e5b840d..c9d683a9cb 100644 --- a/src/tests/perf_tests/DawnPerfTest.cpp +++ b/src/tests/perf_tests/DawnPerfTest.cpp @@ -331,9 +331,9 @@ void DawnPerfTestBase::OutputResults() { } } - PrintPerIterationResultFromMilliseconds("wall_time", mTimer->GetElapsedTime() * 1e3, true); - PrintPerIterationResultFromMilliseconds("validation_time", totalValidationTime, true); - PrintPerIterationResultFromMilliseconds("recording_time", totalRecordingTime, true); + PrintPerIterationResultFromSeconds("wall_time", mTimer->GetElapsedTime(), true); + PrintPerIterationResultFromSeconds("validation_time", totalValidationTime, true); + PrintPerIterationResultFromSeconds("recording_time", totalRecordingTime, true); const char* traceFile = gTestEnv->GetTraceFile(); if (traceFile != nullptr) { @@ -341,23 +341,23 @@ void DawnPerfTestBase::OutputResults() { } } -void DawnPerfTestBase::PrintPerIterationResultFromMilliseconds(const std::string& trace, - double valueInMilliseconds, - bool important) const { - if (valueInMilliseconds == 0) { +void DawnPerfTestBase::PrintPerIterationResultFromSeconds(const std::string& trace, + double valueInSeconds, + bool important) const { + if (valueInSeconds == 0) { return; } - double millisecondsPerIteration = - valueInMilliseconds / static_cast(mNumStepsPerformed * mIterationsPerStep); + double secondsPerIteration = + valueInSeconds / static_cast(mNumStepsPerformed * mIterationsPerStep); // Give the result a different name to ensure separate graphs if we transition. - if (millisecondsPerIteration > 1e3) { - PrintResult(trace, millisecondsPerIteration, "ms", important); - } else if (millisecondsPerIteration > 1) { - PrintResult(trace, millisecondsPerIteration * 1e3, "us", important); + if (secondsPerIteration > 1) { + PrintResult(trace, secondsPerIteration * 1e3, "ms", important); + } else if (secondsPerIteration > 1e-3) { + PrintResult(trace, secondsPerIteration * 1e6, "us", important); } else { - PrintResult(trace, millisecondsPerIteration * 1e6, "ns", important); + PrintResult(trace, secondsPerIteration * 1e9, "ns", important); } } diff --git a/src/tests/perf_tests/DawnPerfTest.h b/src/tests/perf_tests/DawnPerfTest.h index 3107b0585b..b1f4ba1ebc 100644 --- a/src/tests/perf_tests/DawnPerfTest.h +++ b/src/tests/perf_tests/DawnPerfTest.h @@ -73,9 +73,9 @@ class DawnPerfTestBase { void AbortTest(); void RunTest(); - void PrintPerIterationResultFromMilliseconds(const std::string& trace, - double valueInMilliseconds, - bool important) const; + void PrintPerIterationResultFromSeconds(const std::string& trace, + double valueInSeconds, + bool important) const; void PrintResult(const std::string& trace, double value, const std::string& units,