diff --git a/be/benchmark/benchmark_binary_plain_page_v2.hpp b/be/benchmark/benchmark_binary_plain_page_v2.hpp new file mode 100644 index 00000000000000..53f15b6dbe0df2 --- /dev/null +++ b/be/benchmark/benchmark_binary_plain_page_v2.hpp @@ -0,0 +1,233 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include + +#include +#include +#include +#include +#include +#include + +#include "storage/cache/page_cache.h" +#include "storage/segment/binary_plain_page_v2.h" +#include "storage/segment/binary_plain_page_v2_pre_decoder.h" +#include "storage/segment/binary_plain_page_v3.h" +#include "storage/segment/binary_plain_page_v3_pre_decoder.h" +#include "storage/segment/options.h" +#include "storage/segment/page_builder.h" +#include "storage/types.h" +#include "util/slice.h" + +namespace doris { +namespace segment_v2 { + +// Build a fixed corpus of strings of `value_len` bytes each. We reuse the same +// corpus across V2 and V3 so the only variable left is the on-disk layout. A +// deterministic RNG keeps results comparable across runs. +inline std::vector make_corpus(size_t num_elems, size_t value_len) { + std::mt19937 rng(0xC0FFEEu); + std::uniform_int_distribution dist('a', 'z'); + std::vector corpus; + corpus.reserve(num_elems); + for (size_t i = 0; i < num_elems; ++i) { + std::string s(value_len, '\0'); + for (size_t j = 0; j < value_len; ++j) { + s[j] = static_cast(dist(rng)); + } + corpus.emplace_back(std::move(s)); + } + return corpus; +} + +template