MCPcopy Create free account
hub / github.com/ashvardanian/less_slow.cpp / recursion_cost

Function recursion_cost

less_slow.cpp:922–933  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

920
921template <typename sorter_type_, std::size_t length_> //
922static void recursion_cost(bm::State &state) {
923 using element_t = typename sorter_type_::element_t;
924 sorter_type_ sorter;
925 aligned_array<element_t> array(length_);
926 for (auto _ : state) {
927 for (std::size_t i = 0; i != length_; ++i) array[i] = length_ - i;
928 sorter(array.begin(), 0, static_cast<std::ptrdiff_t>(length_ - 1));
929 }
930
931 if (!std::is_sorted(array.begin(), array.end())) state.SkipWithError("Array is not sorted!");
932 state.SetComplexityN(length_);
933}
934
935using recursive_sort_i32s = quick_sort_recurse<std::int32_t>;
936using iterative_sort_i32s = quick_sort_iterate<std::int32_t>;

Callers

nothing calls this directly

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected