benchmark()
Creates a benchmark item that will be run when the benchmark target is
run. The behavior of this function is identical to test()
except for:
- benchmark() has no
is_parallelkeyword because benchmarks are not run in parallel - benchmark() does not automatically add the
MALLOC_PERTURB_environment variable
Defined benchmarks can be run in a backend-agnostic way by calling
meson test --benchmark inside the build dir, or by using backend-specific
commands, such as ninja benchmark or msbuild RUN_TESTS.vcxproj.
Signature
# Creates a benchmark item that will be run when the benchmark target is
void benchmark(
str name, # The *unique* test id
exe | jar | external_program | file | custom_tgt | custom_idx executable, # The program to execute
# Keyword arguments:
args : array[str | file | tgt | external_program] # Arguments to pass to the executable
depends : array[build_tgt | custom_tgt] # specifies that this test depends on the specified
env : env | array[str] | dict[str] # environment variables to set, such as `['NAME1=value1',
priority : int # specifies the priority of a test
protocol : str # specifies how the test results are parsed and can
should_fail : bool # when true the test is considered passed if the
suite : str | array[str] # `'label'` (or array of labels `['label1', 'label2']`)
timeout : int # the amount of seconds the test is allowed to run, a test
verbose : bool # if true, forces the test results to be logged as if `--verbose` was passed
workdir : str # absolute path that will be used as the working directory
)
Arguments
The function benchmark() accepts the following positional arguments:
| Name | Type | Description | Tags |
|---|---|---|---|
name |
str |
The unique test id |
|
executable |
exe | jar | external_program | file | custom_tgt | custom_idx
|
The program to execute. (Since 1.4.0) A CustomTarget is also accepted. |
|
Finally, benchmark()
accepts the following keyword arguments:
| Name | Type | Description | Tags |
|---|---|---|---|
args |
array[str | file | tgt | external_program] |
Arguments to pass to the executable |
|
depends |
array[build_tgt | custom_tgt] |
specifies that this test depends on the specified
target(s), even though it does not take any of them as a command
line argument. This is meant for cases where test finds those
targets internally, e.g. plugins or globbing. Those targets are built
before test is executed even if they have |
(since 0.46.0) |
env |
env | array[str] | dict[str] |
environment variables to set, such as |
|
priority |
int |
specifies the priority of a test. Tests with a higher priority are started before tests with a lower priority. The starting order of tests with identical priorities is implementation-defined. The default priority is 0, negative numbers are permitted. |
(since 0.52.0)
|
protocol |
str |
specifies how the test results are parsed and can
be one of
|
(since 0.50.0)
|
should_fail |
bool |
when true the test is considered passed if the executable returns a non-zero return value (i.e. reports an error) |
|
suite |
str | array[str] |
|
|
timeout |
int |
the amount of seconds the test is allowed to run, a test
that exceeds its time limit is always considered failed, defaults to
30 seconds. Since 0.57 if timeout is |
|
verbose |
bool |
if true, forces the test results to be logged as if |
(since 0.62.0)
|
workdir |
str |
absolute path that will be used as the working directory for the test |
|
The results of the search are