Skip to content

Commit

Permalink
Bazelfying benchmark tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mkruskal-google committed Jun 15, 2022
1 parent 8d5c7f0 commit 537b0ad
Show file tree
Hide file tree
Showing 39 changed files with 1,234 additions and 443 deletions.
4 changes: 0 additions & 4 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ clean-local:
echo "Making clean in googletest"; \
cd third_party/googletest && $(MAKE) $(AM_MAKEFLAGS) clean; \
fi; \
if test -e benchmarks/Makefile; then \
echo "Making clean in benchmarks"; \
cd benchmarks && $(MAKE) $(AM_MAKEFLAGS) clean; \
fi; \
if test -e objectivec/DevTools; then \
echo "Cleaning any ObjC pyc files"; \
rm -f objectivec/DevTools/*.pyc; \
Expand Down
45 changes: 34 additions & 11 deletions benchmarks/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_pkg//:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//:protobuf.bzl", "py_proto_library", "php_proto_library")

################################################################################
# Benchmark Protos
################################################################################

proto_library(
name = "benchmarks_proto",
Expand Down Expand Up @@ -34,6 +39,26 @@ java_proto_library(
],
)

php_proto_library(
name = "benchmarks_php_proto",
srcs = ["benchmarks.proto"],
outs = [
"Benchmarks/BenchmarkDataset.php",
"GPBMetadata/Benchmarks.php",
],
visibility = [
"//benchmarks:__subpackages__",
],
)

py_proto_library(
name = "benchmarks_py_proto",
srcs = ["benchmarks.proto"],
visibility = [
"//benchmarks:__subpackages__",
],
)

proto_library(
name = "google_size_proto",
srcs = [
Expand Down Expand Up @@ -65,19 +90,13 @@ java_proto_library(
],
)

################################################################################
# Distribution files
################################################################################

pkg_files(
name = "dist_files",
srcs = glob(
[
"*",
"python/*.cc",
"util/*.cc",
],
exclude = [
"__init__.py", # not in autotools dist
"go/*",
],
),
srcs = glob(["*"]),
strip_prefix = strip_prefix.from_root(""),
)

Expand All @@ -93,6 +112,10 @@ pkg_filegroup(
"//benchmarks/datasets/google_message2:dist_files",
"//benchmarks/datasets/google_message3:dist_files",
"//benchmarks/datasets/google_message4:dist_files",
"//benchmarks/java:dist_files",
"//benchmarks/php:dist_files",
"//benchmarks/python:dist_files",
"//benchmarks/util:dist_files",
],
visibility = ["//pkg:__pkg__"],
)
337 changes: 0 additions & 337 deletions benchmarks/Makefile.am

This file was deleted.

11 changes: 10 additions & 1 deletion benchmarks/cpp/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("//benchmarks:defs.bzl", "benchmark_test")

cc_binary(
name = "cpp",
name = "cpp_benchmark",
srcs = [
"cpp_benchmark.cc",
],
Expand All @@ -15,6 +16,14 @@ cc_binary(
],
)

benchmark_test(
name = "cpp",
binary = ":cpp_benchmark",
datasets = [
"//benchmarks/datasets",
],
)

pkg_files(
name = "dist_files",
srcs = [
Expand Down
53 changes: 53 additions & 0 deletions benchmarks/datasets/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ filegroup(
],
)

filegroup(
name = "proto3_datasets",
srcs = [
"//benchmarks/datasets/google_message1/proto2:proto3_datasets",
"//benchmarks/datasets/google_message1/proto3:datasets",
"//benchmarks/datasets/google_message2:proto3_datasets",
],
visibility = [
"//benchmarks:__subpackages__",
"//conformance:__subpackages__",
],
)

proto_library(
name = "protos",
visibility = [
Expand Down Expand Up @@ -60,6 +73,46 @@ java_library(
],
)

py_library(
name = "py_protos",
visibility = [
"//benchmarks:__subpackages__",
],
deps = [
"//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_py_proto",
"//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_py_proto",
"//benchmarks/datasets/google_message2:benchmark_message2_py_proto",
"//benchmarks/datasets/google_message3:benchmark_message3_py_proto",
"//benchmarks/datasets/google_message4:benchmark_message4_py_proto",
],
)

filegroup(
name = "php_protos",
visibility = [
"//benchmarks:__subpackages__",
],
srcs = [
"//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_php_proto",
"//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_php_proto",
"//benchmarks/datasets/google_message2:benchmark_message2_php_proto",
],
)

filegroup(
name = "csharp_protos",
visibility = [
"//benchmarks:__subpackages__",
],
srcs = [
"//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_csharp_proto",
"//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_csharp_proto",
"//benchmarks/datasets/google_message2:benchmark_message2_csharp_proto",
"//benchmarks/datasets/google_message3:benchmark_message3_csharp_proto",
"//benchmarks/datasets/google_message4:benchmark_message4_csharp_proto",
],
)

pkg_files(
name = "dist_files",
srcs = ["BUILD.bazel"],
Expand Down
42 changes: 41 additions & 1 deletion benchmarks/datasets/google_message1/proto2/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//:protobuf.bzl", "py_proto_library", "csharp_proto_library")
load("//benchmarks/util:compatibility.bzl", "proto3_data", "php_proto3_library")

filegroup(
name = "datasets",
Expand All @@ -13,12 +15,21 @@ filegroup(
],
)

proto3_data(
name = "proto3_datasets",
srcs = [
"dataset.google_message1_proto2.pb",
],
visibility = [
"//benchmarks/datasets:__pkg__",
],
)

proto_library(
name = "benchmark_message1_proto2_proto",
srcs = [
"benchmark_message1_proto2.proto",
],
strip_import_prefix = "/benchmarks",
visibility = [
"//benchmarks/datasets:__pkg__",
],
Expand All @@ -34,6 +45,14 @@ cc_proto_library(
],
)

csharp_proto_library(
name = "benchmark_message1_proto2_csharp_proto",
srcs = ["benchmark_message1_proto2.proto"],
visibility = [
"//benchmarks/datasets:__pkg__",
],
)

java_proto_library(
name = "benchmark_message1_proto2_java_proto",
visibility = [
Expand All @@ -44,6 +63,27 @@ java_proto_library(
],
)

php_proto3_library(
name = "benchmark_message1_proto2_php_proto",
src = "benchmark_message1_proto2.proto",
outs = [
"Benchmarks/Proto2/GoogleMessage1.php",
"Benchmarks/Proto2/GoogleMessage1SubMessage.php",
"GPBMetadata/BenchmarkMessage1Proto2.php",
],
visibility = [
"//benchmarks/datasets:__pkg__",
],
)

py_proto_library(
name = "benchmark_message1_proto2_py_proto",
srcs = ["benchmark_message1_proto2.proto"],
visibility = [
"//benchmarks/datasets:__pkg__",
],
)

pkg_files(
name = "dist_files",
srcs = glob(["*"]),
Expand Down
31 changes: 30 additions & 1 deletion benchmarks/datasets/google_message1/proto3/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("//:protobuf.bzl", "py_proto_library", "php_proto_library", "csharp_proto_library")

filegroup(
name = "datasets",
Expand All @@ -18,7 +19,6 @@ proto_library(
srcs = [
"benchmark_message1_proto3.proto",
],
strip_import_prefix = "/benchmarks",
visibility = [
"//benchmarks/datasets:__pkg__",
],
Expand All @@ -34,6 +34,14 @@ cc_proto_library(
],
)

csharp_proto_library(
name = "benchmark_message1_proto3_csharp_proto",
srcs = ["benchmark_message1_proto3.proto"],
visibility = [
"//benchmarks/datasets:__pkg__",
],
)

java_proto_library(
name = "benchmark_message1_proto3_java_proto",
visibility = [
Expand All @@ -44,6 +52,27 @@ java_proto_library(
],
)

php_proto_library(
name = "benchmark_message1_proto3_php_proto",
srcs = ["benchmark_message1_proto3.proto"],
outs = [
"Benchmarks/Proto3/GoogleMessage1.php",
"Benchmarks/Proto3/GoogleMessage1SubMessage.php",
"GPBMetadata/BenchmarkMessage1Proto3.php",
],
visibility = [
"//benchmarks/datasets:__pkg__",
],
)

py_proto_library(
name = "benchmark_message1_proto3_py_proto",
srcs = ["benchmark_message1_proto3.proto"],
visibility = [
"//benchmarks/datasets:__pkg__",
],
)

pkg_files(
name = "dist_files",
srcs = glob(["*"]),
Expand Down
42 changes: 41 additions & 1 deletion benchmarks/datasets/google_message2/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//:protobuf.bzl", "py_proto_library", "csharp_proto_library")
load("//benchmarks/util:compatibility.bzl", "proto3_data", "php_proto3_library")

filegroup(
name = "datasets",
Expand All @@ -13,12 +15,21 @@ filegroup(
],
)

proto3_data(
name = "proto3_datasets",
srcs = [
"dataset.google_message2.pb",
],
visibility = [
"//benchmarks/datasets:__pkg__",
],
)

proto_library(
name = "benchmark_message2_proto",
srcs = [
"benchmark_message2.proto",
],
strip_import_prefix = "/benchmarks",
visibility = [
"//benchmarks/datasets:__pkg__",
],
Expand All @@ -34,6 +45,14 @@ cc_proto_library(
],
)

csharp_proto_library(
name = "benchmark_message2_csharp_proto",
srcs = ["benchmark_message2.proto"],
visibility = [
"//benchmarks/datasets:__pkg__",
],
)

java_proto_library(
name = "benchmark_message2_java_proto",
visibility = [
Expand All @@ -44,6 +63,27 @@ java_proto_library(
],
)

php_proto3_library(
name = "benchmark_message2_php_proto",
src = "benchmark_message2.proto",
outs = [
"Benchmarks/Proto2/GoogleMessage2.php",
"Benchmarks/Proto2/GoogleMessage2GroupedMessage.php",
"GPBMetadata/BenchmarkMessage2.php",
],
visibility = [
"//benchmarks/datasets:__pkg__",
],
)

py_proto_library(
name = "benchmark_message2_py_proto",
srcs = ["benchmark_message2.proto"],
visibility = [
"//benchmarks/datasets:__pkg__",
],
)

pkg_files(
name = "dist_files",
srcs = glob(["*"]),
Expand Down
Loading

0 comments on commit 537b0ad

Please sign in to comment.