Add a flag to store perf results as a JSON file.
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 <phoglund@webrtc.org>
Commit-Queue: Edward Lemur <ehmaldonado@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21082}
diff --git a/test/test_main.cc b/test/test_main.cc
index 8bd2ed2..5023ae6 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 @@
"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 @@
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<const uint8_t*>(json_results.c_str()),
+ json_results.size());
+ json_file.Close();
+ }
+
+ return exit_code;
}