From ab63bb576525aa44b0b2becd2fb17f74b2d017aa Mon Sep 17 00:00:00 2001 From: Edward Lemur Date: Mon, 4 Dec 2017 15:56:21 +0100 Subject: [PATCH] Add a flag to store perf results as a JSON file. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a flag to store perf results as a JSON file in the format specified by https://github.com/catapult-project/catapult/blob/master/dashboard/docs/data-format.md Bug: webrtc:7156 Change-Id: Ia5b0317f0f5dc8767fa219f42bc39bf4073203e8 Reviewed-on: https://webrtc-review.googlesource.com/29160 Reviewed-by: Patrik Höglund Commit-Queue: Edward Lemur Cr-Commit-Position: refs/heads/master@{#21082} --- test/test_main.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/test_main.cc b/test/test_main.cc index 8bd2ed2244..5023ae6558 100644 --- a/test/test_main.cc +++ b/test/test_main.cc @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "rtc_base/file.h" #include "rtc_base/flags.h" #include "rtc_base/logging.h" #include "system_wrappers/include/metrics_default.h" @@ -15,6 +16,7 @@ #include "test/gmock.h" #include "test/gtest.h" #include "test/testsupport/fileutils.h" +#include "test/testsupport/perf_test.h" #if defined(WEBRTC_IOS) #include "test/ios/test_support.h" @@ -32,6 +34,14 @@ DEFINE_string(force_fieldtrials, "", "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" " will assign the group Enable to field trial WebRTC-FooFeature."); +DEFINE_string( + perf_results_json_path, + "", + "Path where the perf results should be stored it the JSON format described " + "by " + "https://github.com/catapult-project/catapult/blob/master/dashboard/docs/" + "data-format.md."); + DEFINE_bool(help, false, "Print this message."); int main(int argc, char* argv[]) { @@ -61,5 +71,16 @@ int main(int argc, char* argv[]) { rtc::test::RunTestsFromIOSApp(); #endif - return RUN_ALL_TESTS(); + int exit_code = RUN_ALL_TESTS(); + + std::string perf_results_json_path = FLAG_perf_results_json_path; + if (perf_results_json_path != "") { + std::string json_results = webrtc::test::GetPerfResultsJSON(); + rtc::File json_file = rtc::File::Open(perf_results_json_path); + json_file.Write(reinterpret_cast(json_results.c_str()), + json_results.size()); + json_file.Close(); + } + + return exit_code; }