foundationdb/flowbench/BenchMetadataCheck.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
2.2 KiB
C++
Raw Normal View History

2020-10-11 05:10:40 +08:00
/*
* BenchMetadataCheck.cpp
*
* This source file is part of the FoundationDB open source project
*
2022-03-22 04:36:23 +08:00
* Copyright 2013-2022 Apple Inc. and the FoundationDB project authors
2020-10-11 05:10:40 +08:00
*
* Licensed 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.
*/
#include "benchmark/benchmark.h"
2021-06-03 12:28:37 +08:00
#include "fdbclient/CommitTransaction.h"
2020-10-11 05:10:40 +08:00
#include "fdbclient/FDBTypes.h"
#include "fdbclient/SystemData.h"
// These benchmarks test the performance of different checks methods
// of checking for metadata mutations in applyMetadataMutations
static const std::array<MutationRef, 5> mutations = {
MutationRef(MutationRef::Type::ClearRange, normalKeys.begin, normalKeys.end),
MutationRef(MutationRef::Type::ClearRange, "a"_sr, "b"_sr),
MutationRef(MutationRef::Type::ClearRange, "aaaaaaaaaa"_sr, "bbbbbbbbbb"_sr),
2020-10-11 05:10:40 +08:00
MutationRef(MutationRef::Type::ClearRange, normalKeys.begin, systemKeys.end),
MutationRef(MutationRef::Type::ClearRange,
"a"_sr.withPrefix(systemKeys.begin),
"b"_sr.withPrefix(systemKeys.begin)),
2020-10-11 05:10:40 +08:00
};
static void bench_check_metadata1(benchmark::State& state) {
const auto& m = mutations[state.range(0)];
for (auto _ : state) {
2020-10-11 05:10:40 +08:00
benchmark::DoNotOptimize(KeyRangeRef(m.param1, m.param2).intersects(systemKeys));
}
state.SetItemsProcessed(static_cast<long>(state.iterations()));
}
static void bench_check_metadata2(benchmark::State& state) {
const auto& m = mutations[state.range(0)];
for (auto _ : state) {
2020-10-14 01:43:57 +08:00
benchmark::DoNotOptimize(m.param2.size() > 1 && m.param2[0] == systemKeys.begin[0]);
2020-10-11 05:10:40 +08:00
}
state.SetItemsProcessed(static_cast<long>(state.iterations()));
}
BENCHMARK(bench_check_metadata1)->DenseRange(0, mutations.size() - 1)->ReportAggregatesOnly(true);
BENCHMARK(bench_check_metadata2)->DenseRange(0, mutations.size() - 1)->ReportAggregatesOnly(true);