# Copyright 2022 The Pigweed Authors # # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy of # the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library") load("//pw_build:compatibility.bzl", "host_backend_alias", "incompatible_with_mcu") load("//pw_build:pw_facade.bzl", "pw_facade") load("//pw_perf_test:pw_cc_perf_test.bzl", "pw_cc_perf_test") load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") package( default_visibility = ["//visibility:public"], features = ["-layering_check"], ) licenses(["notice"]) cc_library( name = "pw_perf_test", srcs = [ "framework.cc", "perf_test.cc", "test_info.cc", ], hdrs = [ "public/pw_perf_test/internal/framework.h", "public/pw_perf_test/internal/test_info.h", "public/pw_perf_test/perf_test.h", ], strip_include_prefix = "public", deps = [ ":event_handler", ":state", ":timer", "//pw_preprocessor", ], ) cc_library( name = "state", srcs = [ "state.cc", ], hdrs = [ "public/pw_perf_test/state.h", ], strip_include_prefix = "public", deps = [ ":event_handler", ":timer", "//pw_assert:assert", "//pw_log", ], ) pw_cc_test( name = "state_test", srcs = ["state_test.cc"], deps = [":pw_perf_test"], ) # Event handlers cc_library( name = "event_handler", hdrs = ["public/pw_perf_test/event_handler.h"], strip_include_prefix = "public", deps = [":timer"], ) cc_library( name = "logging_event_handler", srcs = ["logging_event_handler.cc"], hdrs = [ "public/pw_perf_test/googletest_style_event_handler.h", "public/pw_perf_test/logging_event_handler.h", ], strip_include_prefix = "public", deps = [ ":event_handler", "//pw_log", ], ) cc_library( name = "logging_main", srcs = ["logging_main.cc"], deps = [ ":logging_event_handler", ":pw_perf_test", ], ) # Timer facade cc_library( name = "duration_unit", hdrs = [ "public/pw_perf_test/internal/duration_unit.h", ], strip_include_prefix = "public", visibility = ["//visibility:private"], ) pw_facade( name = "timer", hdrs = [ "public/pw_perf_test/internal/timer.h", ], backend = ":test_timer_backend", strip_include_prefix = "public", deps = [ ":duration_unit", ], ) label_flag( name = "test_timer_backend", build_setting_default = ":unspecified_backend", ) host_backend_alias( name = "unspecified_backend", backend = ":chrono_timer", ) pw_cc_test( name = "timer_test", srcs = ["timer_test.cc"], deps = [ ":timer", "//pw_chrono:system_clock", "//pw_thread:sleep", ], ) # Chrono timer facade implementation cc_library( name = "chrono_timer", hdrs = [ "chrono_public_overrides/pw_perf_test_timer_backend/timer.h", "public/pw_perf_test/internal/chrono_timer_interface.h", ], includes = [ "chrono_public_overrides", "public", ], target_compatible_with = incompatible_with_mcu(), deps = [ ":duration_unit", ":timer.facade", "//pw_chrono:system_clock", ], ) pw_cc_test( name = "chrono_timer_test", srcs = ["chrono_test.cc"], deps = [ ":chrono_timer", "//pw_chrono:system_clock", "//pw_thread:sleep", ], ) # ARM Cortex timer facade implementation cc_library( name = "arm_cortex_timer", hdrs = [ "arm_cortex_cyccnt_public_overrides/pw_perf_test_timer_backend/timer.h", "public/pw_perf_test/internal/cyccnt_timer_interface.h", ], includes = [ "arm_cortex_cyccnt_public_overrides", "public", ], target_compatible_with = incompatible_with_mcu(), deps = [ ":duration_unit", ":timer.facade", ], ) # Module-level targets pw_cc_perf_test( name = "example_perf_test", srcs = ["examples/example_perf_test.cc"], ) sphinx_docs_library( name = "docs", srcs = [ "docs.rst", "examples/example_perf_test.cc", ], prefix = "pw_perf_test/", target_compatible_with = incompatible_with_mcu(), ) filegroup( name = "doxygen", srcs = [ "public/pw_perf_test/event_handler.h", "public/pw_perf_test/perf_test.h", ], )