// SPDX-License-Identifier: MIT // SPDX-FileCopyrightText: 2026 Martino Ferrari #pragma once #ifdef PLOT_PYRAMID_COUNT_MERGES #include #include namespace plot::data::detail { /// Test-only instrumentation. Counts the bucket merges the append path has /// performed since the counter was last reset: one for the bucket pushed at /// level 0 when it completes, plus one for every parent bucket written above it. /// /// The append path's *cost* is invisible in every answer -- a pyramid that walks /// every live level per sample returns exactly the same min/max/sum as one that /// stops at the first level that gained no entry -- so a test that wants to pin /// "amortised O(1) per sample, independent of the number of live levels" has to /// count merges. The counter exists only when PLOT_PYRAMID_COUNT_MERGES is /// defined (the test build defines it), so every normal build carries no counter /// and no increment on the append path. /// /// Not part of the query surface and not meant for production use. inline std::atomic& merge_count() { static std::atomic count{0}; return count; } } // namespace plot::data::detail #endif // PLOT_PYRAMID_COUNT_MERGES