1- = cargo-bench(1)
2- :idprefix: cargo_bench_
3- :doctype: manpage
4- :actionverb: Benchmark
5- :nouns: benchmarks
1+ # cargo-bench(1)
2+ {{* set actionverb="Benchmark"}}
3+ {{* set nouns="benchmarks"}}
64
7- == NAME
5+ ## NAME
86
97cargo-bench - Execute benchmarks of a package
108
11- == SYNOPSIS
9+ ## SYNOPSIS
1210
13- ` cargo bench [_OPTIONS_ ] [BENCHNAME ] [-- _BENCH-OPTIONS_] `
11+ ` cargo bench ` [ _ options _ ] [ _ benchname _ ] [ ` -- ` _ bench-options _ ]
1412
15- == DESCRIPTION
13+ ## DESCRIPTION
1614
1715Compile and execute benchmarks.
1816
19- The benchmark filtering argument ` BENCHNAME ` and all the arguments following
17+ The benchmark filtering argument _ benchname _ and all the arguments following
2018the two dashes (` -- ` ) are passed to the benchmark binaries and thus to
21- _ libtest_ (rustc's built in unit-test and micro-benchmarking framework). If
22- you're passing arguments to both Cargo and the binary, the ones after ` -- ` go
23- to the binary, the ones before go to Cargo. For details about libtest's
24- arguments see the output of ` cargo bench \ -- --help ` . As an example, this will
19+ _ libtest_ (rustc's built in unit-test and micro-benchmarking framework). If
20+ you are passing arguments to both Cargo and the binary, the ones after ` -- ` go
21+ to the binary, the ones before go to Cargo. For details about libtest's
22+ arguments see the output of ` cargo bench -- --help ` . As an example, this will
2523run only the benchmark named ` foo ` (and skip other similarly named benchmarks
2624like ` foobar ` ):
2725
@@ -36,27 +34,24 @@ The libtest harness may be disabled by setting `harness = false` in the target
3634manifest settings, in which case your code will need to provide its own ` main `
3735function to handle running benchmarks.
3836
39-
4037> ** Note** : The
41- > link: https://doc.rust-lang.org/nightly/unstable-book/library-features/test.html[`#[bench\ ] ` attribute ]
38+ > [ ` #[bench] ` attribute ] ( https://doc.rust-lang.org/nightly/unstable-book/library-features/test.html )
4239> is currently unstable and only available on the
43- > link: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html[nightly channel ] .
40+ > [ nightly channel ] ( https://doc.rust-lang.org/book/appendix-07-nightly-rust.html ) .
4441> There are some packages available on
45- > link: https://crates.io/keywords/benchmark[crates.io ] that may help with
42+ > [ crates.io ] ( https://crates.io/keywords/benchmark ) that may help with
4643> running benchmarks on the stable channel, such as
47- > link:https://crates.io/crates/criterion[Criterion ] .
48-
49- == OPTIONS
44+ > [ Criterion] ( https://crates.io/crates/criterion ) .
5045
51- === Benchmark Options
46+ ## OPTIONS
5247
53- include::options-test.adoc [ ]
48+ ### Benchmark Options
5449
55- === Package Selection
50+ {{> options-test }}
5651
57- include::options-packages.adoc [ ]
52+ {{> section-package-selection }}
5853
59- === Target Selection
54+ ### Target Selection
6055
6156When no target selection options are given, ` cargo bench ` will build the
6257following targets of the selected packages:
@@ -75,53 +70,65 @@ them from being benchmarked by default. Target selection options that take a
7570target by name ignore the ` bench ` flag and will always benchmark the given
7671target.
7772
78- include::options-targets.adoc[ ]
73+ {{> options-targets }}
74+
75+ {{> section-features }}
7976
80- include::options-features.adoc [ ]
77+ ### Compilation Options
8178
82- === Compilation Options
79+ {{#options}}
8380
84- include:: options-target-triple.adoc [ ]
81+ {{> options-target-triple }}
8582
86- === Output Options
83+ {{/options}}
8784
88- include::options-target-dir.adoc [ ]
85+ ### Output Options
8986
90- === Display Options
87+ {{#options}}
88+ {{> options-target-dir }}
89+ {{/options}}
90+
91+ ### Display Options
9192
9293By default the Rust test harness hides output from benchmark execution to keep
9394results readable. Benchmark output can be recovered (e.g., for debugging) by
9495passing ` --nocapture ` to the benchmark binaries:
9596
9697 cargo bench -- --nocapture
9798
98- include::options-display.adoc[ ]
99+ {{#options}}
100+
101+ {{> options-display }}
99102
100- include:: options-message-format.adoc [ ]
103+ {{> options-message-format }}
101104
102- === Manifest Options
105+ {{/options}}
103106
104- include::options-manifest-path.adoc [ ]
107+ ### Manifest Options
105108
106- include::options-locked.adoc[ ]
109+ {{#options}}
110+ {{> options-manifest-path }}
107111
108- === Common Options
112+ {{> options-locked }}
113+ {{/options}}
109114
110- include:: options-common.adoc [ ]
115+ {{> section- options-common }}
111116
112- === Miscellaneous Options
117+ ### Miscellaneous Options
113118
114119The ` --jobs ` argument affects the building of the benchmark executable but
115120does not affect how many threads are used when running the benchmarks. The
116121Rust test harness runs benchmarks serially in a single thread.
117122
118- include::options-jobs.adoc[ ]
123+ {{#options}}
124+ {{> options-jobs }}
125+ {{/options}}
119126
120- == PROFILES
127+ ## PROFILES
121128
122129Profiles may be used to configure compiler options such as optimization levels
123130and debug settings. See
124- linkcargo : reference /profiles.html [ the reference]
131+ [ the reference] ( ../reference/profiles.html )
125132for more details.
126133
127134Benchmarks are always built with the ` bench ` profile. Binary and lib targets
@@ -130,23 +137,23 @@ are built with the `release` profiles when linked to binaries and benchmarks.
130137Dependencies use the ` release ` profile.
131138
132139If you need a debug build of a benchmark, try building it with
133- man: cargo-build [ 1 ] which will use the ` test ` profile which is by default
140+ {{ man " cargo-build" 1}} which will use the ` test ` profile which is by default
134141unoptimized and includes debug information. You can then run the debug-enabled
135142benchmark manually.
136143
137- include:: section-environment.adoc [ ]
144+ {{> section-environment }}
138145
139- include:: section-exit-status.adoc [ ]
146+ {{> section-exit-status }}
140147
141- == EXAMPLES
148+ ## EXAMPLES
142149
143- . Build and execute all the benchmarks of the current package:
150+ 1 . Build and execute all the benchmarks of the current package:
144151
145- cargo bench
152+ cargo bench
146153
147- . Run only a specific benchmark within a specific benchmark target:
154+ 2 . Run only a specific benchmark within a specific benchmark target:
148155
149- cargo bench --bench bench_name -- modname::some_benchmark
156+ cargo bench --bench bench_name -- modname::some_benchmark
150157
151- == SEE ALSO
152- man: cargo [ 1 ] , man: cargo-test [ 1 ]
158+ ## SEE ALSO
159+ {{ man " cargo" 1}}, {{ man " cargo-test" 1}}
0 commit comments