[benchmark] Add flag to use the Chrome perf format
By default, use the standard Google Benchmark output format, which is
much more readable for people running the benchmark directly. Add a
flag to switch to the Chrome perf format, which will be used on the
waterfall.
Bug: 42251293
Change-Id: I04b7d2231f8a195d26ee7c3a6314e59accf10ca6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/204519
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/cmd/bench/main_bench.cc b/src/tint/cmd/bench/main_bench.cc
index 0f1b8d4..b3f9c01 100644
--- a/src/tint/cmd/bench/main_bench.cc
+++ b/src/tint/cmd/bench/main_bench.cc
@@ -30,6 +30,11 @@
#include "src/tint/cmd/bench/bench.h"
#include "src/tint/utils/text/string.h"
+namespace {
+
+// Toggle to use the Google Benchmark output format instead of the Chromium Perf format.
+static bool use_chrome_perf_format = false;
+
/// ChromePerfReporter is a custom benchmark reporter used to output benchmark results in the format
/// required for the Chrome Perf waterfall, as described here:
/// [chromium]//src/tools/perf/generate_legacy_perf_dashboard_json.py
@@ -82,23 +87,33 @@
bool ParseExtraCommandLineArgs(int argc, char** argv) {
for (int i = 1; i < argc; i++) {
- // Accept the flags that are passed by the Chromium perf waterfall, which treats this
- // executable as a GoogleTest binary.
- if (strcmp(argv[i], "--verbose") != 0 &&
- strcmp(argv[i], "--test-launcher-print-test-stdio=always") != 0 &&
- strcmp(argv[i], "--test-launcher-total-shards=1") != 0 &&
- strcmp(argv[i], "--test-launcher-shard-index=0") != 0) {
- std::cerr << "Unrecognized command-line argument: " << argv[i] << "\n";
- return false;
+ if (strcmp(argv[i], "--use-chrome-perf-format") == 0) {
+ use_chrome_perf_format = true;
+ } else {
+ // Accept the flags that are passed by the Chromium perf waterfall, which treats this
+ // executable as a GoogleTest binary.
+ if (strcmp(argv[i], "--verbose") != 0 &&
+ strcmp(argv[i], "--test-launcher-print-test-stdio=always") != 0 &&
+ strcmp(argv[i], "--test-launcher-total-shards=1") != 0 &&
+ strcmp(argv[i], "--test-launcher-shard-index=0") != 0) {
+ std::cerr << "Unrecognized command-line argument: " << argv[i] << "\n";
+ return false;
+ }
}
}
return true;
}
+} // namespace
+
int main(int argc, char** argv) {
benchmark::Initialize(&argc, argv);
if (!ParseExtraCommandLineArgs(argc, argv)) {
return 1;
}
- benchmark::RunSpecifiedBenchmarks(new ChromePerfReporter);
+ if (use_chrome_perf_format) {
+ benchmark::RunSpecifiedBenchmarks(new ChromePerfReporter);
+ } else {
+ benchmark::RunSpecifiedBenchmarks();
+ }
}