|
@ -4,33 +4,69 @@ |
|
|
#include "ranges/ranges.h" |
|
|
#include "ranges/ranges.h" |
|
|
#include "all_cases/all_cases.h" |
|
|
#include "all_cases/all_cases.h" |
|
|
|
|
|
|
|
|
|
|
|
using klotski::cases::Ranges; |
|
|
using klotski::cases::AllCases; |
|
|
using klotski::cases::AllCases; |
|
|
using klotski::cases::BasicRanges; |
|
|
using klotski::cases::BasicRanges; |
|
|
|
|
|
using klotski::cases::RangesUnion; |
|
|
|
|
|
|
|
|
static void SpawnRanges(benchmark::State &state) { |
|
|
using klotski::group::BLOCK_NUM; |
|
|
// constexpr auto nums = target_nums();
|
|
|
using klotski::cases::ALL_CASES_NUM; |
|
|
|
|
|
using klotski::cases::BASIC_RANGES_NUM_; |
|
|
|
|
|
|
|
|
for (auto _ : state) { |
|
|
Ranges ranges_samples(const size_t num) { |
|
|
|
|
|
auto &ranges = BasicRanges::instance().fetch(); |
|
|
|
|
|
const size_t part_size = ranges.size() / num; |
|
|
|
|
|
const size_t offset = part_size / 2; |
|
|
|
|
|
|
|
|
klotski::cases::Ranges kk {}; |
|
|
Ranges result; |
|
|
kk.reserve(7311921); |
|
|
for (size_t i = 0; i < num; ++i) { |
|
|
|
|
|
result.emplace_back(ranges[i * part_size + offset]); |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// for (uint32_t type_id = 0; type_id < klotski::cases::TYPE_ID_LIMIT; ++type_id) {
|
|
|
static void CheckRanges(benchmark::State &state) { |
|
|
for (auto [n, n_2x1, n_1x1] : klotski::group::BLOCK_NUM) { |
|
|
auto ranges = ranges_samples(state.range(0)); |
|
|
kk.spawn(n, n_2x1, n_1x1); |
|
|
ranges.reverse(); |
|
|
|
|
|
for (auto _ : state) { |
|
|
|
|
|
for (const auto range : ranges) { |
|
|
|
|
|
for (const auto head : RangesUnion::Heads) { |
|
|
|
|
|
benchmark::DoNotOptimize(Ranges::check(static_cast<int>(head), range)); |
|
|
} |
|
|
} |
|
|
// }
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
state.SetItemsProcessed(state.iterations() * state.range(0) * 12); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void RangesReverse(benchmark::State &state) { |
|
|
static void ReverseRanges(benchmark::State &state) { |
|
|
auto ranges = BasicRanges::instance().fetch(); |
|
|
auto ranges = BasicRanges::instance().fetch(); |
|
|
for (auto _ : state) { |
|
|
for (auto _ : state) { |
|
|
ranges.reverse(); |
|
|
ranges.reverse(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void SpawnRanges(benchmark::State &state) { |
|
|
|
|
|
for (auto _ : state) { |
|
|
|
|
|
Ranges ranges {}; |
|
|
|
|
|
ranges.reserve(BASIC_RANGES_NUM_); |
|
|
|
|
|
for (const auto [n, n_2x1, n_1x1] : BLOCK_NUM) { |
|
|
|
|
|
ranges.spawn(n, n_2x1, n_1x1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void DeriveRanges(benchmark::State &state) { |
|
|
|
|
|
auto ranges = BasicRanges::instance().fetch(); |
|
|
|
|
|
ranges.reverse(); |
|
|
|
|
|
for (auto _ : state) { |
|
|
|
|
|
RangesUnion cases; |
|
|
|
|
|
for (const auto head : RangesUnion::Heads) { |
|
|
|
|
|
cases.ranges(head).reserve(ALL_CASES_NUM[head]); |
|
|
|
|
|
ranges.derive(static_cast<int>(head), cases.ranges(head)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
static void RangesUnionExport(benchmark::State &state) { |
|
|
static void RangesUnionExport(benchmark::State &state) { |
|
|
auto &all_cases = AllCases::instance().fetch(); |
|
|
auto &all_cases = AllCases::instance().fetch(); |
|
|
for (auto _ : state) { |
|
|
for (auto _ : state) { |
|
@ -77,14 +113,18 @@ static void RangesAt(benchmark::State &state) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BENCHMARK(CheckRanges)->Unit(benchmark::kMicrosecond)->Range(16, 256); |
|
|
|
|
|
|
|
|
|
|
|
// BENCHMARK(ReverseRanges)->Unit(benchmark::kMillisecond);
|
|
|
|
|
|
|
|
|
// BENCHMARK(SpawnRanges)->Unit(benchmark::kMillisecond);
|
|
|
// BENCHMARK(SpawnRanges)->Unit(benchmark::kMillisecond);
|
|
|
|
|
|
|
|
|
// BENCHMARK(RangesReverse)->Unit(benchmark::kMillisecond);
|
|
|
// BENCHMARK(DeriveRanges)->Unit(benchmark::kMillisecond);
|
|
|
|
|
|
|
|
|
// BENCHMARK(RangesUnionExport)->Unit(benchmark::kMillisecond);
|
|
|
// BENCHMARK(RangesUnionExport)->Unit(benchmark::kMillisecond);
|
|
|
|
|
|
|
|
|
// BENCHMARK(RangesSize);
|
|
|
// BENCHMARK(RangesSize);
|
|
|
|
|
|
|
|
|
BENCHMARK(RangesAt); |
|
|
// BENCHMARK(RangesAt);
|
|
|
|
|
|
|
|
|
BENCHMARK_MAIN(); |
|
|
BENCHMARK_MAIN(); |
|
|