| 920 | |
| 921 | template <typename sorter_type_, std::size_t length_> // |
| 922 | static 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 | |
| 935 | using recursive_sort_i32s = quick_sort_recurse<std::int32_t>; |
| 936 | using iterative_sort_i32s = quick_sort_iterate<std::int32_t>; |