[PCLF] Enable exporting of perf metric via new API

Bug: b/246095034
Change-Id: I05f28e5dfc6df793c035110f89d9ac40783687f8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/276267
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38161}
This commit is contained in:
Artem Titov
2022-09-21 16:08:03 +02:00
committed by WebRTC LUCI CQ
parent cbad8add12
commit 3680605caa
12 changed files with 827 additions and 41 deletions

View File

@ -13,11 +13,15 @@
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include "absl/flags/flag.h"
#include "absl/memory/memory.h"
#include "absl/strings/match.h"
#include "absl/types/optional.h"
#include "api/test/metrics/global_metrics_logger_and_exporter.h"
#include "api/test/metrics/metrics_exporter.h"
#include "api/test/metrics/stdout_metrics_exporter.h"
#include "rtc_base/checks.h"
#include "rtc_base/event_tracer.h"
#include "rtc_base/logging.h"
@ -65,6 +69,11 @@ ABSL_FLAG(std::string,
"",
"Path to output an empty JSON file which Chromium infra requires.");
ABSL_FLAG(bool,
export_perf_results_new_api,
false,
"Tells to initialize new API for exporting performance metrics");
ABSL_FLAG(bool, logs, true, "print logs to stderr");
ABSL_FLAG(bool, verbose, false, "verbose logs to stderr");
@ -101,6 +110,12 @@ class TestMainImpl : public TestMain {
rtc::LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs) ||
absl::GetFlag(FLAGS_verbose));
if (absl::GetFlag(FLAGS_export_perf_results_new_api)) {
std::vector<std::unique_ptr<test::MetricsExporter>> exporters;
exporters.push_back(std::make_unique<test::StdoutMetricsExporter>());
test::SetupGlobalMetricsLoggerAndExporter(std::move(exporters));
}
// InitFieldTrialsFromString stores the char*, so the char array must
// outlive the application.
field_trials_ = absl::GetFlag(FLAGS_force_fieldtrials);
@ -158,6 +173,10 @@ class TestMainImpl : public TestMain {
webrtc::test::PrintPlottableResults(*metrics_to_plot);
}
if (absl::GetFlag(FLAGS_export_perf_results_new_api)) {
test::ExportAndDestroyGlobalMetricsLoggerAndExporter();
}
std::string result_filename =
absl::GetFlag(FLAGS_isolated_script_test_output);
if (!result_filename.empty()) {