mirror of
https://github.com/google/benchmark.git
synced 2024-12-01 07:16:07 +00:00
398a8ac2e8
* Build libpfm as a dependency to allow collection of perf counters This commit builds libpfm using rules_foreign_cc and lets the default build of the benchmark library support perf counter collection without needing additional work from users. Tested with a custom target: ``` bazel run \ --override_repository=com_github_google_benchmark=/home/raghu/benchmark \ -c opt :test-bench -- "--benchmark_perf_counters=INSTRUCTIONS,CYCLES" Using profile: local <snip> ---------------------------------------------------------------------- Benchmark Time CPU Iterations UserCounters... ---------------------------------------------------------------------- BM_Test 0.279 ns 0.279 ns 1000000000 CYCLES=1.00888 INSTRUCTIONS=2 ``` Signed-off-by: Raghu Raja <raghu@enfabrica.net> * Adding myself to the CONTRIBUTORS file per CLA guidance Enfabrica has already signed a corporate CLA. Signed-off-by: Raghu Raja <raghu@enfabrica.net> Signed-off-by: Raghu Raja <raghu@enfabrica.net>
78 lines
1.8 KiB
Python
78 lines
1.8 KiB
Python
licenses(["notice"])
|
|
|
|
config_setting(
|
|
name = "qnx",
|
|
constraint_values = ["@platforms//os:qnx"],
|
|
values = {
|
|
"cpu": "x64_qnx",
|
|
},
|
|
visibility = [":__subpackages__"],
|
|
)
|
|
|
|
config_setting(
|
|
name = "windows",
|
|
constraint_values = ["@platforms//os:windows"],
|
|
values = {
|
|
"cpu": "x64_windows",
|
|
},
|
|
visibility = [":__subpackages__"],
|
|
)
|
|
|
|
config_setting(
|
|
name = "perfcounters",
|
|
define_values = {
|
|
"pfm": "1",
|
|
},
|
|
visibility = [":__subpackages__"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "benchmark",
|
|
srcs = glob(
|
|
[
|
|
"src/*.cc",
|
|
"src/*.h",
|
|
],
|
|
exclude = ["src/benchmark_main.cc"],
|
|
),
|
|
hdrs = [
|
|
"include/benchmark/benchmark.h",
|
|
"include/benchmark/export.h",
|
|
],
|
|
linkopts = select({
|
|
":windows": ["-DEFAULTLIB:shlwapi.lib"],
|
|
"//conditions:default": ["-pthread"],
|
|
}),
|
|
strip_include_prefix = "include",
|
|
visibility = ["//visibility:public"],
|
|
# Only static linking is allowed; no .so will be produced.
|
|
# Using `defines` (i.e. not `local_defines`) means that no
|
|
# dependent rules need to bother about defining the macro.
|
|
linkstatic = True,
|
|
defines = [
|
|
"BENCHMARK_STATIC_DEFINE",
|
|
] + select({
|
|
":perfcounters": ["HAVE_LIBPFM"],
|
|
"//conditions:default": [],
|
|
}),
|
|
deps = select({
|
|
":perfcounters": ["@libpfm//:libpfm"],
|
|
"//conditions:default": [],
|
|
}),
|
|
)
|
|
|
|
cc_library(
|
|
name = "benchmark_main",
|
|
srcs = ["src/benchmark_main.cc"],
|
|
hdrs = ["include/benchmark/benchmark.h", "include/benchmark/export.h"],
|
|
strip_include_prefix = "include",
|
|
visibility = ["//visibility:public"],
|
|
deps = [":benchmark"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "benchmark_internal_headers",
|
|
hdrs = glob(["src/*.h"]),
|
|
visibility = ["//test:__pkg__"],
|
|
)
|