-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsonar_benchmark.cpp
42 lines (31 loc) · 915 Bytes
/
sonar_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
// 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 <catch2/catch_test_macros.hpp>
#include <nanobench.h>
#include <nameof.hpp>
#include "forfun/sonar.hpp"
TEST_CASE("Sonar benchmarking", "[benchmark][sonar]")
{
using namespace forfun::sonar;
sonar const sonar{{
{.x = 0, .y = 7},
{.x = 2, .y = 5},
{.x = 3, .y = 3},
{.x = 4, .y = 6},
{.x = 5, .y = 2},
}};
ankerl::nanobench::Bench()
.title("Sonar")
.relative(true)
.run(
NAMEOF(count_ships).c_str(),
[&sonar]() noexcept {
ankerl::nanobench::doNotOptimizeAway(count_ships(
sonar, {.top = 0, .bottom = 5, .left = 2, .right = 7}
));
}
)
;
}