xref: /aosp_15_r20/external/pigweed/pw_allocator/benchmarks/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2024 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
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pw_build/target_types.gni")
18import("$dir_pw_chrono/backend.gni")
19import("$dir_pw_unit_test/test.gni")
20
21group("benchmarks") {
22  deps = [
23    ":best_fit_benchmark",
24    ":dual_first_fit_benchmark",
25    ":first_fit_benchmark",
26    ":last_fit_benchmark",
27    ":worst_fit_benchmark",
28  ]
29}
30
31config("public_include_path") {
32  include_dirs = [ "public" ]
33  visibility = [ ":*" ]
34}
35
36# Libraries
37
38pw_source_set("measurements") {
39  public_configs = [ ":public_include_path" ]
40  public = [ "public/pw_allocator/benchmarks/measurements.h" ]
41  public_deps = [
42    "$dir_pw_chrono:system_clock",
43    "$dir_pw_containers:intrusive_map",
44    dir_pw_metric,
45  ]
46  sources = [ "measurements.cc" ]
47}
48
49pw_source_set("benchmark") {
50  public_configs = [ ":public_include_path" ]
51  public = [
52    "public/pw_allocator/benchmarks/benchmark.h",
53    "public/pw_allocator/benchmarks/config.h",
54  ]
55  public_deps = [
56    ":measurements",
57    "$dir_pw_allocator:block_allocator",
58    "$dir_pw_allocator:fragmentation",
59    "$dir_pw_allocator:test_harness",
60    "$dir_pw_chrono:system_clock",
61    dir_pw_metric,
62    dir_pw_tokenizer,
63  ]
64  sources = [ "benchmark.cc" ]
65}
66
67# Binaries
68
69pw_executable("best_fit_benchmark") {
70  sources = [ "best_fit_benchmark.cc" ]
71  deps = [
72    ":benchmark",
73    "$dir_pw_allocator:best_fit",
74    "$dir_pw_random",
75  ]
76}
77
78pw_executable("dual_first_fit_benchmark") {
79  sources = [ "dual_first_fit_benchmark.cc" ]
80  deps = [
81    ":benchmark",
82    "$dir_pw_allocator:first_fit",
83    "$dir_pw_random",
84  ]
85}
86
87pw_executable("first_fit_benchmark") {
88  sources = [ "first_fit_benchmark.cc" ]
89  deps = [
90    ":benchmark",
91    "$dir_pw_allocator:first_fit",
92    "$dir_pw_random",
93  ]
94}
95
96pw_executable("last_fit_benchmark") {
97  sources = [ "last_fit_benchmark.cc" ]
98  deps = [
99    ":benchmark",
100    "$dir_pw_allocator:first_fit",
101    "$dir_pw_random",
102  ]
103}
104
105pw_executable("worst_fit_benchmark") {
106  sources = [ "worst_fit_benchmark.cc" ]
107  deps = [
108    ":benchmark",
109    "$dir_pw_allocator:worst_fit",
110    "$dir_pw_random",
111  ]
112}
113
114# Unit tests
115
116pw_test("measurements_test") {
117  enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != ""
118  deps = [ ":measurements" ]
119  sources = [ "measurements_test.cc" ]
120}
121
122pw_test("benchmark_test") {
123  enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != ""
124  deps = [
125    ":benchmark",
126    "$dir_pw_allocator:testing",
127  ]
128  sources = [ "benchmark_test.cc" ]
129}
130
131pw_test_group("tests") {
132  tests = [
133    ":benchmark_test",
134    ":measurements_test",
135  ]
136}
137