|
|
@ -14,7 +14,7 @@ using klotski::cases::ALL_CASES_NUM; |
|
|
|
using klotski::cases::ALL_CASES_NUM_; |
|
|
|
using klotski::cases::BASIC_RANGES_NUM_; |
|
|
|
|
|
|
|
Ranges ranges_samples(const size_t num) { |
|
|
|
static 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; |
|
|
@ -27,7 +27,7 @@ Ranges ranges_samples(const size_t num) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
std::vector<size_t> all_cases_index_samples(const size_t num) { |
|
|
|
static std::vector<size_t> all_cases_index_samples(const size_t num) { |
|
|
|
const size_t part_size = ALL_CASES_NUM_ / num; |
|
|
|
const size_t offset = part_size / 2; |
|
|
|
|
|
|
@ -39,14 +39,14 @@ std::vector<size_t> all_cases_index_samples(const size_t num) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
static void RangesReverse(benchmark::State &state) { |
|
|
|
static void BM_RangesReverse(benchmark::State &state) { |
|
|
|
auto ranges = BasicRanges::instance().fetch(); |
|
|
|
for (auto _ : state) { |
|
|
|
ranges.reverse(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static void RangesCheck(benchmark::State &state) { |
|
|
|
static void BM_RangesCheck(benchmark::State &state) { |
|
|
|
auto ranges = ranges_samples(state.range(0)); |
|
|
|
ranges.reverse(); |
|
|
|
for (auto _ : state) { |
|
|
@ -59,7 +59,7 @@ static void RangesCheck(benchmark::State &state) { |
|
|
|
state.SetItemsProcessed(state.iterations() * state.range(0) * 12); |
|
|
|
} |
|
|
|
|
|
|
|
static void RangesSpawn(benchmark::State &state) { |
|
|
|
static void BM_RangesSpawn(benchmark::State &state) { |
|
|
|
for (auto _ : state) { |
|
|
|
Ranges ranges {}; |
|
|
|
ranges.reserve(BASIC_RANGES_NUM_); |
|
|
@ -69,7 +69,7 @@ static void RangesSpawn(benchmark::State &state) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static void RangesDerive(benchmark::State &state) { |
|
|
|
static void BM_RangesDerive(benchmark::State &state) { |
|
|
|
auto ranges = BasicRanges::instance().fetch(); |
|
|
|
ranges.reverse(); |
|
|
|
for (auto _ : state) { |
|
|
@ -81,7 +81,7 @@ static void RangesDerive(benchmark::State &state) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static void RangesUnionAt(benchmark::State &state) { |
|
|
|
static void BM_RangesUnionAt(benchmark::State &state) { |
|
|
|
const auto &all_cases = AllCases::instance().fetch(); |
|
|
|
const auto samples = all_cases_index_samples(state.range(0)); |
|
|
|
for (auto _ : state) { |
|
|
@ -92,7 +92,7 @@ static void RangesUnionAt(benchmark::State &state) { |
|
|
|
state.SetItemsProcessed(state.iterations() * state.range(0)); |
|
|
|
} |
|
|
|
|
|
|
|
static void RangesUnionSize(benchmark::State &state) { |
|
|
|
static void BM_RangesUnionSize(benchmark::State &state) { |
|
|
|
auto &all_cases = AllCases::instance().fetch(); |
|
|
|
for (auto _ : state) { |
|
|
|
for (int i = 0; i < state.range(0); ++i) { |
|
|
@ -102,7 +102,7 @@ static void RangesUnionSize(benchmark::State &state) { |
|
|
|
state.SetItemsProcessed(state.iterations() * state.range(0)); |
|
|
|
} |
|
|
|
|
|
|
|
static void RangesUnionExport(benchmark::State &state) { |
|
|
|
static void BM_RangesUnionExport(benchmark::State &state) { |
|
|
|
auto &all_cases = AllCases::instance().fetch(); |
|
|
|
for (auto _ : state) { |
|
|
|
auto codes = all_cases.codes(); |
|
|
@ -110,14 +110,14 @@ static void RangesUnionExport(benchmark::State &state) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
BENCHMARK(RangesReverse)->Unit(benchmark::kMillisecond); |
|
|
|
BENCHMARK(RangesCheck)->Unit(benchmark::kMicrosecond)->Range(16, 256); |
|
|
|
BENCHMARK(BM_RangesReverse)->Unit(benchmark::kMillisecond); |
|
|
|
BENCHMARK(BM_RangesCheck)->Unit(benchmark::kMicrosecond)->Range(16, 256); |
|
|
|
|
|
|
|
BENCHMARK(RangesSpawn)->Unit(benchmark::kMillisecond); |
|
|
|
BENCHMARK(RangesDerive)->Unit(benchmark::kMillisecond); |
|
|
|
BENCHMARK(BM_RangesSpawn)->Unit(benchmark::kMillisecond); |
|
|
|
BENCHMARK(BM_RangesDerive)->Unit(benchmark::kMillisecond); |
|
|
|
|
|
|
|
BENCHMARK(RangesUnionAt)->Range(16, 256); |
|
|
|
BENCHMARK(RangesUnionSize)->Range(16, 256); |
|
|
|
BENCHMARK(RangesUnionExport)->Unit(benchmark::kMillisecond); |
|
|
|
BENCHMARK(BM_RangesUnionAt)->Range(16, 256); |
|
|
|
BENCHMARK(BM_RangesUnionSize)->Range(16, 256); |
|
|
|
BENCHMARK(BM_RangesUnionExport)->Unit(benchmark::kMillisecond); |
|
|
|
|
|
|
|
BENCHMARK_MAIN(); |
|
|
|