• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_allocator,
62    dir_pw_assert,
63    dir_pw_metric,
64    dir_pw_tokenizer,
65  ]
66  sources = [ "benchmark.cc" ]
67}
68
69# Binaries
70
71pw_executable("best_fit_benchmark") {
72  sources = [ "best_fit_benchmark.cc" ]
73  deps = [
74    ":benchmark",
75    "$dir_pw_allocator:best_fit",
76    dir_pw_random,
77  ]
78}
79
80pw_executable("dual_first_fit_benchmark") {
81  sources = [ "dual_first_fit_benchmark.cc" ]
82  deps = [
83    ":benchmark",
84    "$dir_pw_allocator:first_fit",
85    dir_pw_random,
86  ]
87}
88
89pw_executable("first_fit_benchmark") {
90  sources = [ "first_fit_benchmark.cc" ]
91  deps = [
92    ":benchmark",
93    "$dir_pw_allocator:first_fit",
94    dir_pw_random,
95  ]
96}
97
98pw_executable("last_fit_benchmark") {
99  sources = [ "last_fit_benchmark.cc" ]
100  deps = [
101    ":benchmark",
102    "$dir_pw_allocator:first_fit",
103    dir_pw_random,
104  ]
105}
106
107pw_executable("tlsf_benchmark") {
108  sources = [ "tlsf_benchmark.cc" ]
109  deps = [
110    ":benchmark",
111    "$dir_pw_allocator:tlsf_allocator",
112    dir_pw_random,
113  ]
114}
115
116pw_executable("worst_fit_benchmark") {
117  sources = [ "worst_fit_benchmark.cc" ]
118  deps = [
119    ":benchmark",
120    "$dir_pw_allocator:worst_fit",
121    dir_pw_random,
122  ]
123}
124
125# Unit tests
126
127pw_test("measurements_test") {
128  enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != ""
129  deps = [
130    ":measurements",
131    dir_pw_metric,
132  ]
133  sources = [ "measurements_test.cc" ]
134}
135
136pw_test("benchmark_test") {
137  enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != ""
138  deps = [
139    ":benchmark",
140    ":measurements",
141    "$dir_pw_allocator:fragmentation",
142    "$dir_pw_allocator:test_harness",
143    "$dir_pw_allocator:testing",
144    dir_pw_random,
145  ]
146  sources = [ "benchmark_test.cc" ]
147}
148
149pw_test_group("tests") {
150  tests = [
151    ":benchmark_test",
152    ":measurements_test",
153  ]
154}
155