C/C++ API Reference
Loading...
Searching...
No Matches
perf_test.h
1// Copyright 2022 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14#pragma once
15
16#include "pw_perf_test/event_handler.h"
17#include "pw_perf_test/internal/test_info.h"
18#include "pw_perf_test/state.h"
19#include "pw_preprocessor/arguments.h"
20
22
39#define PW_PERF_TEST(name, function, ...) \
40 const ::pw::perf_test::internal::TestInfo PwPerfTest_##name( \
41 #name, [](::pw::perf_test::State& pw_perf_test_state) { \
42 static_cast<void>( \
43 function(pw_perf_test_state PW_COMMA_ARGS(__VA_ARGS__))); \
44 })
45
60#define PW_PERF_TEST_SIMPLE(name, function, ...) \
61 PW_PERF_TEST( \
62 name, \
63 [](::pw::perf_test::State& pw_perf_test_simple_state, \
64 const auto&... args) { \
65 while (pw_perf_test_simple_state.KeepRunning()) { \
66 function(args...); \
67 } \
68 }, \
69 __VA_ARGS__)
70
71namespace pw::perf_test {
72
78
79} // namespace pw::perf_test
Definition: event_handler.h:51
void RunAllTests(EventHandler &handler)
Micro-benchmarks library.
Definition: event_handler.h:19