-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontains_duplicate_benchmark.cpp
48 lines (34 loc) · 1.25 KB
/
contains_duplicate_benchmark.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) Omar Boukli-Hacene. All rights reserved.
// Distributed under an MIT-style license that can be
// found in the LICENSE file.
// SPDX-License-Identifier: MIT
#include <array>
#include <utility>
#include <catch2/catch_test_macros.hpp>
#include <nanobench.h>
#include <nameof.hpp>
#include "forfun/contains_duplicate.hpp"
TEST_CASE("Contains duplicate benchmarking", "[benchmark][contains_duplicate]")
{
using namespace forfun::contains_duplicate;
using ContainerType = std::array<int, 32U>;
using Itr = ContainerType::iterator;
constexpr std::array const superprimes{
3, 5, 11, 17, 31, 41, 59, 67, 83, 109, 127,
157, 179, 191, 211, 241, 277, 283, 331, 353, 367, 401,
431, 461, 509, 547, 563, 587, 599, 617, 709, 739,
};
static_assert(superprimes.size() == std::tuple_size<ContainerType>::value);
ankerl::nanobench::Bench()
.title("Contains duplicate")
.relative(true)
.run(
NAMEOF_RAW(contains_duplicate<Itr, Itr>).c_str(),
[&superprimes]() noexcept {
ankerl::nanobench::doNotOptimizeAway(
contains_duplicate(superprimes.cbegin(), superprimes.cend())
);
}
)
;
}