1 //===----------------------------------------------------------------------===//
2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //===----------------------------------------------------------------------===//
14 #include "benchmark/benchmark.h"
16 constexpr std::size_t MAX_BUFFER_LEN
= 256;
17 constexpr std::size_t MAX_SEED_LEN
= 16;
19 static void BM_SeedSeq_Generate(benchmark::State
& state
) {
20 std::array
<std::uint32_t, MAX_BUFFER_LEN
> buffer
;
21 std::array
<std::uint32_t, MAX_SEED_LEN
> seeds
;
23 std::random_device rd
;
24 std::generate(std::begin(seeds
), std::begin(seeds
) + state
.range(0), [&]() { return rd(); });
26 std::seed_seq
seed(std::begin(seeds
), std::begin(seeds
) + state
.range(0));
27 for (auto _
: state
) {
28 seed
.generate(std::begin(buffer
), std::begin(buffer
) + state
.range(1));
31 BENCHMARK(BM_SeedSeq_Generate
)->Ranges({{1, MAX_SEED_LEN
}, {1, MAX_BUFFER_LEN
}});