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