perf_tests: Fixup perf test result printing format

Results should be printed METRIC: STORY, not the other way around.
Also, story names shouldn't have slashes as it will parse as separate
chart segments and won't be allowed when we switch to using histograms.

Bug: dawn:208, dawn:311
Change-Id: Ifc893e5aa94eddcb3a08c0d4aff66b7a0f41620b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14740
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
diff --git a/src/tests/perf_tests/DawnPerfTest.cpp b/src/tests/perf_tests/DawnPerfTest.cpp
index 8fd3ab8..3bd641b 100644
--- a/src/tests/perf_tests/DawnPerfTest.cpp
+++ b/src/tests/perf_tests/DawnPerfTest.cpp
@@ -381,30 +381,30 @@
                                    double value,
                                    const std::string& units,
                                    bool important) const {
-    const ::testing::TestInfo* const testInfo =
-        ::testing::UnitTest::GetInstance()->current_test_info();
-
-    const char* testName = testInfo->name();
-    const char* testSuite = testInfo->test_suite_name();
-
-    // The results are printed according to the format specified at
-    // [chromium]//build/scripts/slave/performance_log_processor.py
-    dawn::InfoLog() << (important ? "*" : "") << "RESULT " << testSuite << testName << ": " << trace
-                    << "= " << value << " " << units;
+    PrintResultImpl(trace, std::to_string(value), units, important);
 }
 
 void DawnPerfTestBase::PrintResult(const std::string& trace,
                                    unsigned int value,
                                    const std::string& units,
                                    bool important) const {
+    PrintResultImpl(trace, std::to_string(value), units, important);
+}
+
+void DawnPerfTestBase::PrintResultImpl(const std::string& trace,
+                                       const std::string& value,
+                                       const std::string& units,
+                                       bool important) const {
     const ::testing::TestInfo* const testInfo =
         ::testing::UnitTest::GetInstance()->current_test_info();
 
-    const char* testName = testInfo->name();
-    const char* testSuite = testInfo->test_suite_name();
+    std::string metric = std::string(testInfo->test_suite_name()) + "." + trace;
+
+    std::string story = testInfo->name();
+    std::replace(story.begin(), story.end(), '/', '_');
 
     // The results are printed according to the format specified at
-    // [chromium]//build/scripts/slave/performance_log_processor.py
-    dawn::InfoLog() << (important ? "*" : "") << "RESULT " << testSuite << testName << ": " << trace
-                    << "= " << value << " " << units;
+    // [chromium]//src/tools/perf/generate_legacy_perf_dashboard_json.py
+    dawn::InfoLog() << (important ? "*" : "") << "RESULT " << metric << ": " << story << "= "
+                    << value << " " << units;
 }
diff --git a/src/tests/perf_tests/DawnPerfTest.h b/src/tests/perf_tests/DawnPerfTest.h
index b514b1c..64ef6dc 100644
--- a/src/tests/perf_tests/DawnPerfTest.h
+++ b/src/tests/perf_tests/DawnPerfTest.h
@@ -91,6 +91,11 @@
     void DoRunLoop(double maxRunTime);
     void OutputResults();
 
+    void PrintResultImpl(const std::string& trace,
+                         const std::string& value,
+                         const std::string& units,
+                         bool important) const;
+
     virtual void Step() = 0;
 
     DawnTestBase* mTest;