ORM C++
Loading...
Searching...
No Matches
perf_test_seam.cppm
Go to the documentation of this file.
1module;
2
3#include <cstddef>
4#include <optional>
5#include <span>
6#include <stdexcept>
7
8export module orm:perf_test_seam;
9
10import :database_context;
11
12/**
13 * Internal perf-test seam for the benchmark gate (variant C).
14 *
15 * Compiled and exported only when ORM_CXX_ENABLE_PERF_TEST_SEAM=ON. It calls the same
16 * production insertManyImpl as the public API and differs only in the chunk policy.
17 */
18namespace orm::detail::perf_seam
19{
20class TestAccess
21{
22public:
23 template <typename SchemaType, typename T>
24 static auto insertManyWithChunkRows(OrmContext<SchemaType>& context, std::span<const T> rows,
25 std::size_t chunkRows) -> void
26 {
27 context.template insertManyImpl<T>(rows, std::optional<std::size_t>{chunkRows});
28 }
29};
30
31export [[nodiscard]] inline auto defaultChunkRowsForTest() noexcept -> std::size_t
32{
33 return insertManyDefaultRowBudget;
34}
35
36export template <typename SchemaType, typename T>
37auto insertManyWithChunkRowsForTest(OrmContext<SchemaType>& context, std::span<const T> rows,
38 std::size_t chunkRows) -> void
39{
40 if (chunkRows == 0)
41 {
42 throw std::invalid_argument{"A batch insert chunk cannot be empty"};
43 }
44 TestAccess::insertManyWithChunkRows(context, rows, chunkRows);
45}
46} // namespace orm::detail::perf_seam