1//! @file benchmark.hpp
2//! @author ryftchen
3//! @brief The declarations (benchmark) in the utility module.
4//! @version 0.1.0
5//! @copyright Copyright (c) 2022-2025 ryftchen. All rights reserved.
6
7#pragma once
8
9//! @brief The utility module.
10namespace utility // NOLINT(modernize-concat-nested-namespaces)
11{
12//! @brief Benchmark-related functions in the utility module.
13namespace benchmark
14{
15//! @brief Brief function description.
16//! @return function description (module_function)
17inline static const char* description() noexcept
18{
19 return "UTIL_BENCHMARK";
20}
21extern const char* version() noexcept;
22
23// NOLINTBEGIN(hicpp-no-assembler)
24//! @brief Escape the pointer to prevent optimization. Used for benchmark.
25//! @param p - pointer to escape
26inline void escape(const void* const p) noexcept
27{
28 asm volatile("" : : "g"(p) : "memory");
29}
30
31//! @brief Clobber the memory to prevent optimization. Used for benchmark.
32inline void clobber() noexcept
33{
34 asm volatile("" : : : "memory");
35}
36// NOLINTEND(hicpp-no-assembler)
37} // namespace benchmark
38} // namespace utility
39