Skip to content

Commit 75fb909

Browse files
committed
Use resize instead of reserve so that sort_benchmark actually benchmarks sorting
1 parent 8b10497 commit 75fb909

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

source/containers/test/sort/sort_benchmark.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,25 @@ using namespace bounded::literal;
1818

1919
template<std::size_t size>
2020
struct data {
21+
data() = default;
2122
constexpr explicit data(unsigned value) {
2223
for (auto const n : containers::integer_range(bounded::constant<size>)) {
2324
m[n] = static_cast<std::uint8_t>(value);
2425
}
2526
}
2627
friend constexpr auto operator<=>(data const & lhs, data const & rhs) = default;
27-
containers::array<std::uint8_t, bounded::constant<size>> m;
28+
29+
containers::array<std::uint8_t, bounded::constant<size>> m = {};
2830
};
2931

3032
template<std::size_t data_size, auto function>
3133
auto benchmark_sort(benchmark::State & state) -> void {
3234
auto engine = std::mt19937(std::random_device()());
3335
auto value_distribution = std::uniform_int_distribution<unsigned>();
3436
using container_t = containers::vector<data<data_size>>;
35-
auto container = container_t();
3637
using size_type = containers::range_size_t<container_t>;
3738
auto const size = bounded::assume_in_range<size_type>(state.range(0));
38-
container.reserve(size);
39+
auto container = container_t(containers::repeat_default_n<data<data_size>>(size));
3940

4041
for (auto _ : state) {
4142
containers::copy(

0 commit comments

Comments
 (0)