[bazel] Add //bench/BazelBenchmarkRunner.cpp and some sample targets.

This benchmark runner borrows a lot of code from nanobench (https://skia.googlesource.com/skia/+/a063eaeaf1e09e4d6f42e0f44a5723622a46d21c/bench/nanobench.cpp).

This benchmark runner produces an output directory with a results.json file that can be uploaded to Perf, plus any PNGs produced by the benchmarks under test.

It differs from nanobench in the following key ways:

- There is no backend-dependent code in BazelBenchmarkRunner.cpp. Instead, backend-specific stuff is delegated to a BenchmarkTarget class, which has multiple implementations, analogous to SurfaceManager.

- Surface creation code is shared with BazelGMRunner.cpp in that BenchmarkTarget uses a SurfaceManager under the hood.

- I did not port nanobench's BenchmarkStream class (https://skia.googlesource.com/skia/+/a063eaeaf1e09e4d6f42e0f44a5723622a46d21c/bench/nanobench.cpp#783) into BazelBenchmarkRunner.cpp. Instead, I just iterate over BenchRegistry::Range() to get the benchmarks under test.

- For benchmarks that depend on resource files, such as SKPs (https://skia.googlesource.com/skia/+/a063eaeaf1e09e4d6f42e0f44a5723622a46d21c/bench/nanobench.cpp#941), we can add a mechanism similar to BazelGMRunner.cpp's registry of GM registerer functions (https://skia.googlesource.com/skia/+/a063eaeaf1e09e4d6f42e0f44a5723622a46d21c/gm/BazelGMRunner.cpp#280). Then, we can add a new .cpp file that dynamically registers the various kinds of benchmarks that nanobench registers today for each SKP it finds (similar to //gm/png_codec.cpp, see https://skia.googlesource.com/skia/+/a063eaeaf1e09e4d6f42e0f44a5723622a46d21c/gm/png_codec.cpp#509).

- I did not backport any of the TRACE_EVENT* macro calls (see https://skia.googlesource.com/skia/+/a063eaeaf1e09e4d6f42e0f44a5723622a46d21c/bench/nanobench.cpp#1484). I will tackle these in a follow-up CL.

- I've only ported the subset of nanobench's CLI flags that are currently used in CI tasks, plus some that I found useful while debugging. We can backport more flags later as needed.

Bug: b/40045301
Change-Id: Icdc4d72eff41e988e135394a588ba84ff798aa02
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/762118
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Leandro Lovisolo <lovisolo@google.com>
14 files changed