Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Zephyr Benchmarking Framework

Macros

#define ZTEST_BENCHMARK_SUITE(suite, setup_fn, teardown_fn)
 Define a benchmark suite.
#define ZTEST_BENCHMARK(suite_name, benchmark, samples, setup_fn, teardown_fn)
 Define a benchmark with setup and teardown functions.
#define ZTEST_BENCHMARK_TIMED(testsuite, benchmark, duration, setup_fn, teardown_fn)
 Define a timed benchmark with setup and teardown functions.

Detailed Description

Macro Definition Documentation

◆ ZTEST_BENCHMARK

#define ZTEST_BENCHMARK ( suite_name,
benchmark,
samples,
setup_fn,
teardown_fn )

#include </__w/zephyr/zephyr/subsys/testsuite/ztest/include/zephyr/benchmark.h>

Value:
static __noinline void Z_ZTEST_BENCHMARK_FN(suite_name, benchmark)(void); \
static const STRUCT_SECTION_ITERABLE(ztest_benchmark, \
Z_ZTEST_BENCHMARK_NODE(suite_name, benchmark)) = \
{ \
.name = #benchmark, \
.iterations = samples, \
.setup = setup_fn, \
.teardown = teardown_fn, \
.run = Z_ZTEST_BENCHMARK_FN(suite_name, benchmark), \
.suite = &Z_ZTEST_BENCHMARK_SUITE_NODE(suite_name), \
}; \
static __noinline void Z_ZTEST_BENCHMARK_FN(suite_name, benchmark)(void)
#define STRUCT_SECTION_ITERABLE(struct_type, varname)
Defines a new element for an iterable section.
Definition iterable_sections.h:216

Define a benchmark with setup and teardown functions.

Parameters
suite_nameName of the suite the benchmark belongs to
benchmarkName of the benchmark
samplesNumber of iterations to run the benchmark
setup_fnFunction to run before the benchmark
teardown_fnFunction to run after the benchmark

◆ ZTEST_BENCHMARK_SUITE

#define ZTEST_BENCHMARK_SUITE ( suite,
setup_fn,
teardown_fn )

#include </__w/zephyr/zephyr/subsys/testsuite/ztest/include/zephyr/benchmark.h>

Value:
static const STRUCT_SECTION_ITERABLE(ztest_benchmark_suite, \
Z_ZTEST_BENCHMARK_SUITE_NODE(suite)) = \
{ \
.name = #suite, \
.setup = setup_fn, \
.teardown = teardown_fn, \
}

Define a benchmark suite.

Parameters
suiteName of the suite
setup_fnFunction to run before the suite
teardown_fnFunction to run after the suite

◆ ZTEST_BENCHMARK_TIMED

#define ZTEST_BENCHMARK_TIMED ( testsuite,
benchmark,
duration,
setup_fn,
teardown_fn )

#include </__w/zephyr/zephyr/subsys/testsuite/ztest/include/zephyr/benchmark.h>

Value:
static __noinline void Z_ZTEST_BENCHMARK_FN(testsuite, benchmark)(void); \
static const STRUCT_SECTION_ITERABLE(ztest_benchmark_timed, \
Z_ZTEST_BENCHMARK_TIMED_NODE(testsuite, benchmark)) = \
{ \
.name = #benchmark, \
.duration_ms = duration, \
.setup = setup_fn, \
.run = Z_ZTEST_BENCHMARK_FN(testsuite, benchmark), \
.teardown = teardown_fn, \
.suite = &Z_ZTEST_BENCHMARK_SUITE_NODE(testsuite), \
}; \
static __noinline void Z_ZTEST_BENCHMARK_FN(testsuite, benchmark)(void)

Define a timed benchmark with setup and teardown functions.

Parameters
testsuiteName of the suite the benchmark belongs to
benchmarkName of the benchmark
durationDuration in milliseconds to run the benchmark
setup_fnFunction to run before the benchmark
teardown_fnFunction to run after the benchmark