Toolbox snapshot
The Reactive C++ Toolbox
Loading...
Searching...
No Matches
Benchmark.hpp
Go to the documentation of this file.
1// The Reactive C++ Toolbox.
2// Copyright (C) 2021 Reactive Markets Limited
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#ifndef TOOLBOX_BM_BENCHMARK_HPP
17#define TOOLBOX_BM_BENCHMARK_HPP
18
19#include <toolbox/Config.h>
20
21namespace toolbox::bm {
22class Context;
23
25 Benchmark(const char* name, void (*fn)(Context&));
26 const char* const name;
27 void (*fn)(Context&);
28};
29
30namespace detail {
31TOOLBOX_API int main(int argc, char* argv[]);
32} // namespace detail
33} // namespace toolbox::bm
34
35#define TOOLBOX_BENCHMARK(NAME) \
36 namespace benchmark::NAME { \
37 void fn(::toolbox::bm::Context& ctx); \
38 ::toolbox::bm::Benchmark bm{#NAME, fn}; \
39 } \
40 void benchmark::NAME::fn(toolbox::bm::Context& ctx)
41
42#define TOOLBOX_BENCHMARK_MAIN \
43 int main(int argc, char* argv[]) \
44 { \
45 return toolbox::bm::detail::main(argc, argv); \
46 }
47
48#endif // TOOLBOX_BM_BENCHMARK_HPP
#define TOOLBOX_API
Definition Config.h:39
int main()
Definition EchoClnt.cpp:184
constexpr auto bind() noexcept
Definition Slot.hpp:92
const char *const name
Definition Benchmark.hpp:26