-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add palindromic number non-STL implementation
- Loading branch information
Showing
5 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 <type_traits> | ||
|
||
#include <catch2/catch_test_macros.hpp> | ||
|
||
#include <nanobench.h> | ||
|
||
#include <nameof.hpp> | ||
|
||
#include "forfun/palindromic_number.hpp" | ||
|
||
inline constexpr int const p{1234554321}; | ||
|
||
TEST_CASE( | ||
"palindromic_number benchmarking", "[benchmark][palindromic_number]") { | ||
static_assert(p >= 0 && p <= std::numeric_limits<decltype(p)>::max()); | ||
|
||
ankerl::nanobench::Bench() | ||
|
||
.title("Palindromic number") | ||
|
||
.run( | ||
NAMEOF_RAW(forfun::palindromic_number::fast::is_palindrome).c_str(), | ||
[]() { | ||
auto r{forfun::palindromic_number::fast::is_palindrome(p)}; | ||
ankerl::nanobench::doNotOptimizeAway(r); | ||
}) | ||
|
||
.run( | ||
NAMEOF_RAW(forfun::palindromic_number::stl::is_palindrome).c_str(), | ||
[]() { | ||
auto r{forfun::palindromic_number::stl::is_palindrome(p)}; | ||
ankerl::nanobench::doNotOptimizeAway(r); | ||
}) | ||
|
||
; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters