• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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("@rules_cc//cc:cc_binary.bzl", "cc_binary")
16load("@rules_cc//cc:cc_library.bzl", "cc_library")
17load(
18    "//pw_build:pigweed.bzl",
19    "pw_cc_test",
20)
21
22package(default_visibility = ["//visibility:public"])
23
24licenses(["notice"])
25
26# Libraries
27
28cc_library(
29    name = "measurements",
30    testonly = True,
31    srcs = [
32        "measurements.cc",
33    ],
34    hdrs = [
35        "public/pw_allocator/benchmarks/measurements.h",
36    ],
37    strip_include_prefix = "public",
38    deps = [
39        "//pw_chrono:system_clock",
40        "//pw_containers:intrusive_map",
41        "//pw_metric:metric",
42    ],
43)
44
45cc_library(
46    name = "benchmark",
47    testonly = True,
48    srcs = [
49        "benchmark.cc",
50    ],
51    hdrs = [
52        "public/pw_allocator/benchmarks/benchmark.h",
53        "public/pw_allocator/benchmarks/config.h",
54    ],
55    implementation_deps = ["//pw_assert:check"],
56    strip_include_prefix = "public",
57    target_compatible_with = select({
58        "@platforms//os:linux": [],
59        "//conditions:default": ["@platforms//:incompatible"],
60    }),
61    deps = [
62        ":measurements",
63        "//pw_allocator",
64        "//pw_allocator:block_allocator",
65        "//pw_allocator:fragmentation",
66        "//pw_allocator:test_harness",
67        "//pw_chrono:system_clock",
68        "//pw_metric:metric",
69        "//pw_tokenizer",
70    ],
71)
72
73# Binaries
74
75cc_binary(
76    name = "best_fit_benchmark",
77    testonly = True,
78    srcs = [
79        "best_fit_benchmark.cc",
80    ],
81    deps = [
82        ":benchmark",
83        "//pw_allocator:best_fit",
84        "//pw_random",
85    ],
86)
87
88cc_binary(
89    name = "dual_first_fit_benchmark",
90    testonly = True,
91    srcs = [
92        "dual_first_fit_benchmark.cc",
93    ],
94    deps = [
95        ":benchmark",
96        "//pw_allocator:first_fit",
97        "//pw_random",
98    ],
99)
100
101cc_binary(
102    name = "first_fit_benchmark",
103    testonly = True,
104    srcs = [
105        "first_fit_benchmark.cc",
106    ],
107    deps = [
108        ":benchmark",
109        "//pw_allocator:first_fit",
110        "//pw_random",
111    ],
112)
113
114cc_binary(
115    name = "last_fit_benchmark",
116    testonly = True,
117    srcs = [
118        "last_fit_benchmark.cc",
119    ],
120    deps = [
121        ":benchmark",
122        "//pw_allocator:first_fit",
123        "//pw_random",
124    ],
125)
126
127cc_binary(
128    name = "tlsf_benchmark",
129    testonly = True,
130    srcs = [
131        "tlsf_benchmark.cc",
132    ],
133    deps = [
134        ":benchmark",
135        "//pw_allocator:tlsf_allocator",
136        "//pw_random",
137    ],
138)
139
140cc_binary(
141    name = "worst_fit_benchmark",
142    testonly = True,
143    srcs = [
144        "worst_fit_benchmark.cc",
145    ],
146    deps = [
147        ":benchmark",
148        "//pw_allocator:worst_fit",
149        "//pw_random",
150    ],
151)
152
153# Unit tests
154
155pw_cc_test(
156    name = "measurements_test",
157    srcs = ["measurements_test.cc"],
158    deps = [
159        ":measurements",
160        "//pw_metric:metric",
161    ],
162)
163
164pw_cc_test(
165    name = "benchmark_test",
166    srcs = ["benchmark_test.cc"],
167    deps = [
168        ":benchmark",
169        ":measurements",
170        "//pw_allocator:fragmentation",
171        "//pw_allocator:test_harness",
172        "//pw_allocator:testing",
173        "//pw_random",
174    ],
175)
176