1# Copyright 2020 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15load( 16 "//pw_build:pigweed.bzl", 17 "pw_cc_test", 18) 19 20package(default_visibility = ["//visibility:public"]) 21 22licenses(["notice"]) 23 24# Libraries 25 26cc_library( 27 name = "measurements", 28 testonly = True, 29 srcs = [ 30 "measurements.cc", 31 ], 32 hdrs = [ 33 "public/pw_allocator/benchmarks/measurements.h", 34 ], 35 strip_include_prefix = "public", 36 deps = [ 37 "//pw_chrono:system_clock", 38 "//pw_containers:intrusive_map", 39 "//pw_metric:metric", 40 ], 41) 42 43cc_library( 44 name = "benchmark", 45 testonly = True, 46 srcs = [ 47 "benchmark.cc", 48 ], 49 hdrs = [ 50 "public/pw_allocator/benchmarks/benchmark.h", 51 "public/pw_allocator/benchmarks/config.h", 52 ], 53 strip_include_prefix = "public", 54 target_compatible_with = select({ 55 "@platforms//os:linux": [], 56 "//conditions:default": ["@platforms//:incompatible"], 57 }), 58 deps = [ 59 ":measurements", 60 "//pw_allocator:block_allocator", 61 "//pw_allocator:fragmentation", 62 "//pw_allocator:test_harness", 63 "//pw_chrono:system_clock", 64 "//pw_metric:metric", 65 "//pw_tokenizer", 66 ], 67) 68 69# Binaries 70 71cc_binary( 72 name = "best_fit_benchmark", 73 testonly = True, 74 srcs = [ 75 "best_fit_benchmark.cc", 76 ], 77 deps = [ 78 ":benchmark", 79 "//pw_allocator:best_fit", 80 "//pw_random", 81 ], 82) 83 84cc_binary( 85 name = "dual_first_fit_benchmark", 86 testonly = True, 87 srcs = [ 88 "dual_first_fit_benchmark.cc", 89 ], 90 deps = [ 91 ":benchmark", 92 "//pw_allocator:first_fit", 93 "//pw_random", 94 ], 95) 96 97cc_binary( 98 name = "first_fit_benchmark", 99 testonly = True, 100 srcs = [ 101 "first_fit_benchmark.cc", 102 ], 103 deps = [ 104 ":benchmark", 105 "//pw_allocator:first_fit", 106 "//pw_random", 107 ], 108) 109 110cc_binary( 111 name = "last_fit_benchmark", 112 testonly = True, 113 srcs = [ 114 "last_fit_benchmark.cc", 115 ], 116 deps = [ 117 ":benchmark", 118 "//pw_allocator:first_fit", 119 "//pw_random", 120 ], 121) 122 123cc_binary( 124 name = "worst_fit_benchmark", 125 testonly = True, 126 srcs = [ 127 "worst_fit_benchmark.cc", 128 ], 129 deps = [ 130 ":benchmark", 131 "//pw_allocator:worst_fit", 132 "//pw_random", 133 ], 134) 135 136# Unit tests 137 138pw_cc_test( 139 name = "measurements_test", 140 srcs = ["measurements_test.cc"], 141 deps = [":measurements"], 142) 143 144pw_cc_test( 145 name = "benchmark_test", 146 srcs = ["benchmark_test.cc"], 147 deps = [ 148 ":benchmark", 149 "//pw_allocator:testing", 150 ], 151) 152