Skip to content

Commit f88a3a3

Browse files
authored
Revise benchmarks (#373)
1 parent 1abcf53 commit f88a3a3

File tree

10 files changed

+614
-354
lines changed

10 files changed

+614
-354
lines changed

.github/workflows/bvt-clang.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: build and run test with clang 20
2222
run: |
2323
cmake -B build -GNinja -DCMAKE_C_COMPILER=clang-20 -DCMAKE_CXX_COMPILER=clang++-20 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_CXX_STANDARD=23 -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=TRUE
24-
mapfile -t FILES < <(find include tests benchmarks build/examples_from_docs -type f \( -name '*.h' -o -name '*.ixx' -o -name '*.cpp' \))
24+
mapfile -t FILES < <(find include tests benchmarks build/examples_from_docs tools -type f \( -name '*.h' -o -name '*.ixx' -o -name '*.cpp' \))
2525
echo "Running clang-format on ${#FILES[@]} files: ${FILES[*]}"
2626
clang-format-20 --dry-run --Werror "${FILES[@]}"
2727
cmake --build build -j

benchmarks/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable google benchmark unit t
1717
FetchContent_MakeAvailable(benchmark)
1818

1919
add_executable(msft_proxy_benchmarks
20-
proxy_invocation_benchmark_context.cpp
21-
proxy_invocation_benchmark.cpp
22-
proxy_management_benchmark.cpp
20+
proxy_creation_benchmark.cpp
21+
proxy_operation_benchmark_context.cpp
22+
proxy_operation_benchmark.cpp
2323
)
2424
target_include_directories(msft_proxy_benchmarks PRIVATE .)
2525
target_link_libraries(msft_proxy_benchmarks PRIVATE msft_proxy4::proxy benchmark::benchmark benchmark::benchmark_main)
Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ constexpr int TestManagedObjectCount = 600000;
3030
constexpr int TypeSeriesCount = 3;
3131

3232
using SmallObject1 = int;
33-
using SmallObject2 = std::shared_ptr<int>;
33+
using SmallObject2 = double;
3434
struct SmallObject3 {
3535
SmallObject3() noexcept = default;
3636
SmallObject3(SmallObject3&&) noexcept = default;
3737
SmallObject3(const SmallObject3&) {
3838
throw std::runtime_error{"Not implemented"};
3939
}
4040

41-
std::unique_lock<std::mutex> Field1;
41+
std::unique_ptr<int> Field1;
4242
};
4343

4444
using LargeObject1 = std::array<char, 100>;
@@ -58,9 +58,10 @@ struct PolymorphicObject : PolymorphicObjectBase {
5858

5959
struct DefaultFacade : pro::facade_builder //
6060
::support_copy<pro::constraint_level::nontrivial> //
61+
::add_skill<pro::skills::slim> //
6162
::build {};
6263

63-
void BM_SmallObjectManagementWithProxy(benchmark::State& state) {
64+
void BM_SmallObjectCreationWithProxy(benchmark::State& state) {
6465
for (auto _ : state) {
6566
std::vector<pro::proxy<DefaultFacade>> data;
6667
data.reserve(TestManagedObjectCount);
@@ -73,7 +74,7 @@ void BM_SmallObjectManagementWithProxy(benchmark::State& state) {
7374
}
7475
}
7576

76-
void BM_SmallObjectManagementWithProxy_Shared(benchmark::State& state) {
77+
void BM_SmallObjectCreationWithProxy_Shared(benchmark::State& state) {
7778
for (auto _ : state) {
7879
std::vector<pro::proxy<DefaultFacade>> data;
7980
data.reserve(TestManagedObjectCount);
@@ -86,7 +87,7 @@ void BM_SmallObjectManagementWithProxy_Shared(benchmark::State& state) {
8687
}
8788
}
8889

89-
void BM_SmallObjectManagementWithProxy_SharedPooled(benchmark::State& state) {
90+
void BM_SmallObjectCreationWithProxy_SharedPooled(benchmark::State& state) {
9091
static std::pmr::unsynchronized_pool_resource pool;
9192
std::pmr::polymorphic_allocator<> alloc{&pool};
9293
for (auto _ : state) {
@@ -104,7 +105,7 @@ void BM_SmallObjectManagementWithProxy_SharedPooled(benchmark::State& state) {
104105
}
105106
}
106107

107-
void BM_SmallObjectManagementWithUniquePtr(benchmark::State& state) {
108+
void BM_SmallObjectCreationWithUniquePtr(benchmark::State& state) {
108109
for (auto _ : state) {
109110
std::vector<std::unique_ptr<PolymorphicObjectBase>> data;
110111
data.reserve(TestManagedObjectCount);
@@ -120,7 +121,7 @@ void BM_SmallObjectManagementWithUniquePtr(benchmark::State& state) {
120121
}
121122
}
122123

123-
void BM_SmallObjectManagementWithSharedPtr(benchmark::State& state) {
124+
void BM_SmallObjectCreationWithSharedPtr(benchmark::State& state) {
124125
for (auto _ : state) {
125126
std::vector<std::shared_ptr<void>> data;
126127
data.reserve(TestManagedObjectCount);
@@ -133,7 +134,7 @@ void BM_SmallObjectManagementWithSharedPtr(benchmark::State& state) {
133134
}
134135
}
135136

136-
void BM_SmallObjectManagementWithSharedPtr_Pooled(benchmark::State& state) {
137+
void BM_SmallObjectCreationWithSharedPtr_Pooled(benchmark::State& state) {
137138
static std::pmr::unsynchronized_pool_resource pool;
138139
std::pmr::polymorphic_allocator<> alloc{&pool};
139140
for (auto _ : state) {
@@ -148,7 +149,7 @@ void BM_SmallObjectManagementWithSharedPtr_Pooled(benchmark::State& state) {
148149
}
149150
}
150151

151-
void BM_SmallObjectManagementWithAny(benchmark::State& state) {
152+
void BM_SmallObjectCreationWithAny(benchmark::State& state) {
152153
for (auto _ : state) {
153154
std::vector<std::any> data;
154155
data.reserve(TestManagedObjectCount);
@@ -161,7 +162,7 @@ void BM_SmallObjectManagementWithAny(benchmark::State& state) {
161162
}
162163
}
163164

164-
void BM_LargeObjectManagementWithProxy(benchmark::State& state) {
165+
void BM_LargeObjectCreationWithProxy(benchmark::State& state) {
165166
for (auto _ : state) {
166167
std::vector<pro::proxy<DefaultFacade>> data;
167168
data.reserve(TestManagedObjectCount);
@@ -174,7 +175,7 @@ void BM_LargeObjectManagementWithProxy(benchmark::State& state) {
174175
}
175176
}
176177

177-
void BM_LargeObjectManagementWithProxy_Pooled(benchmark::State& state) {
178+
void BM_LargeObjectCreationWithProxy_Pooled(benchmark::State& state) {
178179
static std::pmr::unsynchronized_pool_resource pool;
179180
std::pmr::polymorphic_allocator<> alloc{&pool};
180181
for (auto _ : state) {
@@ -189,7 +190,7 @@ void BM_LargeObjectManagementWithProxy_Pooled(benchmark::State& state) {
189190
}
190191
}
191192

192-
void BM_LargeObjectManagementWithProxy_Shared(benchmark::State& state) {
193+
void BM_LargeObjectCreationWithProxy_Shared(benchmark::State& state) {
193194
for (auto _ : state) {
194195
std::vector<pro::proxy<DefaultFacade>> data;
195196
data.reserve(TestManagedObjectCount);
@@ -202,7 +203,7 @@ void BM_LargeObjectManagementWithProxy_Shared(benchmark::State& state) {
202203
}
203204
}
204205

205-
void BM_LargeObjectManagementWithProxy_SharedPooled(benchmark::State& state) {
206+
void BM_LargeObjectCreationWithProxy_SharedPooled(benchmark::State& state) {
206207
static std::pmr::unsynchronized_pool_resource pool;
207208
std::pmr::polymorphic_allocator<> alloc{&pool};
208209
for (auto _ : state) {
@@ -220,7 +221,7 @@ void BM_LargeObjectManagementWithProxy_SharedPooled(benchmark::State& state) {
220221
}
221222
}
222223

223-
void BM_LargeObjectManagementWithUniquePtr(benchmark::State& state) {
224+
void BM_LargeObjectCreationWithUniquePtr(benchmark::State& state) {
224225
for (auto _ : state) {
225226
std::vector<std::unique_ptr<PolymorphicObjectBase>> data;
226227
data.reserve(TestManagedObjectCount);
@@ -236,7 +237,7 @@ void BM_LargeObjectManagementWithUniquePtr(benchmark::State& state) {
236237
}
237238
}
238239

239-
void BM_LargeObjectManagementWithSharedPtr(benchmark::State& state) {
240+
void BM_LargeObjectCreationWithSharedPtr(benchmark::State& state) {
240241
for (auto _ : state) {
241242
std::vector<std::shared_ptr<void>> data;
242243
data.reserve(TestManagedObjectCount);
@@ -249,7 +250,7 @@ void BM_LargeObjectManagementWithSharedPtr(benchmark::State& state) {
249250
}
250251
}
251252

252-
void BM_LargeObjectManagementWithSharedPtr_Pooled(benchmark::State& state) {
253+
void BM_LargeObjectCreationWithSharedPtr_Pooled(benchmark::State& state) {
253254
static std::pmr::unsynchronized_pool_resource pool;
254255
std::pmr::polymorphic_allocator<> alloc{&pool};
255256
for (auto _ : state) {
@@ -264,7 +265,7 @@ void BM_LargeObjectManagementWithSharedPtr_Pooled(benchmark::State& state) {
264265
}
265266
}
266267

267-
void BM_LargeObjectManagementWithAny(benchmark::State& state) {
268+
void BM_LargeObjectCreationWithAny(benchmark::State& state) {
268269
for (auto _ : state) {
269270
std::vector<std::any> data;
270271
data.reserve(TestManagedObjectCount);
@@ -277,20 +278,20 @@ void BM_LargeObjectManagementWithAny(benchmark::State& state) {
277278
}
278279
}
279280

280-
BENCHMARK(BM_SmallObjectManagementWithProxy);
281-
BENCHMARK(BM_SmallObjectManagementWithProxy_Shared);
282-
BENCHMARK(BM_SmallObjectManagementWithProxy_SharedPooled);
283-
BENCHMARK(BM_SmallObjectManagementWithUniquePtr);
284-
BENCHMARK(BM_SmallObjectManagementWithSharedPtr);
285-
BENCHMARK(BM_SmallObjectManagementWithSharedPtr_Pooled);
286-
BENCHMARK(BM_SmallObjectManagementWithAny);
287-
BENCHMARK(BM_LargeObjectManagementWithProxy);
288-
BENCHMARK(BM_LargeObjectManagementWithProxy_Pooled);
289-
BENCHMARK(BM_LargeObjectManagementWithProxy_Shared);
290-
BENCHMARK(BM_LargeObjectManagementWithProxy_SharedPooled);
291-
BENCHMARK(BM_LargeObjectManagementWithUniquePtr);
292-
BENCHMARK(BM_LargeObjectManagementWithSharedPtr);
293-
BENCHMARK(BM_LargeObjectManagementWithSharedPtr_Pooled);
294-
BENCHMARK(BM_LargeObjectManagementWithAny);
281+
BENCHMARK(BM_SmallObjectCreationWithProxy);
282+
BENCHMARK(BM_SmallObjectCreationWithProxy_Shared);
283+
BENCHMARK(BM_SmallObjectCreationWithProxy_SharedPooled);
284+
BENCHMARK(BM_SmallObjectCreationWithUniquePtr);
285+
BENCHMARK(BM_SmallObjectCreationWithSharedPtr);
286+
BENCHMARK(BM_SmallObjectCreationWithSharedPtr_Pooled);
287+
BENCHMARK(BM_SmallObjectCreationWithAny);
288+
BENCHMARK(BM_LargeObjectCreationWithProxy);
289+
BENCHMARK(BM_LargeObjectCreationWithProxy_Pooled);
290+
BENCHMARK(BM_LargeObjectCreationWithProxy_Shared);
291+
BENCHMARK(BM_LargeObjectCreationWithProxy_SharedPooled);
292+
BENCHMARK(BM_LargeObjectCreationWithUniquePtr);
293+
BENCHMARK(BM_LargeObjectCreationWithSharedPtr);
294+
BENCHMARK(BM_LargeObjectCreationWithSharedPtr_Pooled);
295+
BENCHMARK(BM_LargeObjectCreationWithAny);
295296

296297
} // namespace

benchmarks/proxy_invocation_benchmark.cpp

Lines changed: 0 additions & 129 deletions
This file was deleted.

benchmarks/proxy_invocation_benchmark_context.h

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)