Skip to content

Commit a0104fb

Browse files
authored
Deleted rust_benchmark rule (#938)
1 parent 20cec2e commit a0104fb

File tree

86 files changed

+0
-7023
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+0
-7023
lines changed

docs/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ PAGES = dict([
5757
"rust_static_library",
5858
"rust_shared_library",
5959
"rust_proc_macro",
60-
"rust_benchmark",
6160
"rust_test",
6261
"rust_test_suite",
6362
"error_format",

docs/defs.md

Lines changed: 0 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* [rust_static_library](#rust_static_library)
77
* [rust_shared_library](#rust_shared_library)
88
* [rust_proc_macro](#rust_proc_macro)
9-
* [rust_benchmark](#rust_benchmark)
109
* [rust_test](#rust_test)
1110
* [rust_test_suite](#rust_test_suite)
1211
* [error_format](#error_format)
@@ -48,116 +47,6 @@ Add additional rustc_flags from the command line with `--@rules_rust//:extra_rus
4847
| <a id="extra_rustc_flags-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
4948

5049

51-
<a id="#rust_benchmark"></a>
52-
53-
## rust_benchmark
54-
55-
<pre>
56-
rust_benchmark(<a href="#rust_benchmark-name">name</a>, <a href="#rust_benchmark-aliases">aliases</a>, <a href="#rust_benchmark-compile_data">compile_data</a>, <a href="#rust_benchmark-crate_features">crate_features</a>, <a href="#rust_benchmark-crate_name">crate_name</a>, <a href="#rust_benchmark-crate_root">crate_root</a>, <a href="#rust_benchmark-data">data</a>,
57-
<a href="#rust_benchmark-default_args">default_args</a>, <a href="#rust_benchmark-deps">deps</a>, <a href="#rust_benchmark-edition">edition</a>, <a href="#rust_benchmark-proc_macro_deps">proc_macro_deps</a>, <a href="#rust_benchmark-rustc_env">rustc_env</a>, <a href="#rust_benchmark-rustc_env_files">rustc_env_files</a>, <a href="#rust_benchmark-rustc_flags">rustc_flags</a>,
58-
<a href="#rust_benchmark-srcs">srcs</a>, <a href="#rust_benchmark-use_libtest_harness">use_libtest_harness</a>, <a href="#rust_benchmark-version">version</a>)
59-
</pre>
60-
61-
Builds a Rust benchmark test.
62-
63-
**Warning**: This rule is currently experimental. [Rust Benchmark tests][rust-bench] require the `Bencher` interface in the unstable `libtest` crate, which is behind the `test` unstable feature gate. As a result, using this rule would require using a nightly binary release of Rust.
64-
65-
[rust-bench]: https://doc.rust-lang.org/nightly/unstable-book/library-features/test.html
66-
67-
Example:
68-
69-
Suppose you have the following directory structure for a Rust project with a library crate, `fibonacci` with benchmarks under the `benches/` directory:
70-
71-
```output
72-
[workspace]/
73-
WORKSPACE
74-
fibonacci/
75-
BUILD
76-
src/
77-
lib.rs
78-
benches/
79-
fibonacci_bench.rs
80-
```
81-
82-
`fibonacci/src/lib.rs`:
83-
```rust
84-
pub fn fibonacci(n: u64) -> u64 {
85-
if n < 2 {
86-
return n;
87-
}
88-
let mut n1: u64 = 0;
89-
let mut n2: u64 = 1;
90-
for _ in 1..n {
91-
let sum = n1 + n2;
92-
n1 = n2;
93-
n2 = sum;
94-
}
95-
n2
96-
}
97-
```
98-
99-
`fibonacci/benches/fibonacci_bench.rs`:
100-
```rust
101-
#![feature(test)]
102-
103-
extern crate test;
104-
extern crate fibonacci;
105-
106-
use test::Bencher;
107-
108-
#[bench]
109-
fn bench_fibonacci(b: &mut Bencher) {
110-
b.iter(|| fibonacci::fibonacci(40));
111-
}
112-
```
113-
114-
To build the benchmark test, add a `rust_benchmark` target:
115-
116-
`fibonacci/BUILD`:
117-
```python
118-
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_benchmark")
119-
120-
package(default_visibility = ["//visibility:public"])
121-
122-
rust_library(
123-
name = "fibonacci",
124-
srcs = ["src/lib.rs"],
125-
)
126-
127-
rust_benchmark(
128-
name = "fibonacci_bench",
129-
srcs = ["benches/fibonacci_bench.rs"],
130-
deps = [":fibonacci"],
131-
)
132-
```
133-
134-
Run the benchmark test using: `bazel run //fibonacci:fibonacci_bench`.
135-
136-
137-
**ATTRIBUTES**
138-
139-
140-
| Name | Description | Type | Mandatory | Default |
141-
| :------------- | :------------- | :------------- | :------------- | :------------- |
142-
| <a id="rust_benchmark-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
143-
| <a id="rust_benchmark-aliases"></a>aliases | Remap crates to a new name or moniker for linkage to this target<br><br>These are other <code>rust_library</code> targets and will be presented as the new name given. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: Label -> String</a> | optional | {} |
144-
| <a id="rust_benchmark-compile_data"></a>compile_data | List of files used by this rule at compile time.<br><br>This attribute can be used to specify any data files that are embedded into the library, such as via the [<code>include_str!</code>](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
145-
| <a id="rust_benchmark-crate_features"></a>crate_features | List of features to enable for this crate.<br><br>Features are defined in the code using the <code>#[cfg(feature = "foo")]</code> configuration option. The features listed here will be passed to <code>rustc</code> with <code>--cfg feature="${feature_name}"</code> flags. | List of strings | optional | [] |
146-
| <a id="rust_benchmark-crate_name"></a>crate_name | Crate name to use for this target.<br><br>This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores. | String | optional | "" |
147-
| <a id="rust_benchmark-crate_root"></a>crate_root | The file that will be passed to <code>rustc</code> to be used for building this crate.<br><br>If <code>crate_root</code> is not set, then this rule will look for a <code>lib.rs</code> file (or <code>main.rs</code> for rust_binary) or the single file in <code>srcs</code> if <code>srcs</code> contains only one file. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
148-
| <a id="rust_benchmark-data"></a>data | List of files used by this rule at compile time and runtime.<br><br>If including data at compile time with include_str!() and similar, prefer <code>compile_data</code> over <code>data</code>, to prevent the data also being included in the runfiles. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
149-
| <a id="rust_benchmark-default_args"></a>default_args | The default arguments to pass to the benchmark binary. This attribute is used if the built-in <code>args</code> attribute is not set. | List of strings | optional | ["--bench"] |
150-
| <a id="rust_benchmark-deps"></a>deps | List of other libraries to be linked to this library target.<br><br>These can be either other <code>rust_library</code> targets or <code>cc_library</code> targets if linking a native library. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
151-
| <a id="rust_benchmark-edition"></a>edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | "" |
152-
| <a id="rust_benchmark-proc_macro_deps"></a>proc_macro_deps | List of <code>rust_library</code> targets with kind <code>proc-macro</code> used to help build this library target. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
153-
| <a id="rust_benchmark-rustc_env"></a>rustc_env | Dictionary of additional <code>"key": "value"</code> environment variables to set for rustc.<br><br>rust_test()/rust_binary() rules can use $(rootpath //package:target) to pass in the location of a generated file or external tool. Cargo build scripts that wish to expand locations should use cargo_build_script()'s build_script_env argument instead, as build scripts are run in a different environment - see cargo_build_script()'s documentation for more. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
154-
| <a id="rust_benchmark-rustc_env_files"></a>rustc_env_files | Files containing additional environment variables to set for rustc.<br><br>These files should contain a single variable per line, of format <code>NAME=value</code>, and newlines may be included in a value by ending a line with a trailing back-slash (<code>\</code>).<br><br>The order that these files will be processed is unspecified, so multiple definitions of a particular variable are discouraged. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
155-
| <a id="rust_benchmark-rustc_flags"></a>rustc_flags | List of compiler flags passed to <code>rustc</code>.<br><br>These strings are subject to Make variable expansion for predefined source/output path variables like <code>$location</code>, <code>$execpath</code>, and <code>$rootpath</code>. This expansion is useful if you wish to pass a generated file of arguments to rustc: <code>@$(location //package:target)</code>. | List of strings | optional | [] |
156-
| <a id="rust_benchmark-srcs"></a>srcs | List of Rust <code>.rs</code> source files used to build the library.<br><br>If <code>srcs</code> contains more than one file, then there must be a file either named <code>lib.rs</code>. Otherwise, <code>crate_root</code> must be set to the source file that is the root of the crate to be passed to rustc to build this crate. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
157-
| <a id="rust_benchmark-use_libtest_harness"></a>use_libtest_harness | Generate the test harness for this benchmark. Note that [Criterion](https://bheisler.github.io/criterion.rs/book/index.html) benchmarks do not use a test harness, but the nightly <code>#[bench]</code> api does. Pass True if you have a <code>#[bench]</code> api test. | Boolean | optional | False |
158-
| <a id="rust_benchmark-version"></a>version | A version to inject in the cargo environment variable. | String | optional | "0.0.0" |
159-
160-
16150
<a id="#rust_binary"></a>
16251

16352
## rust_binary

docs/flatten.md

Lines changed: 0 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* [incompatible_flag](#incompatible_flag)
1515
* [rust_analyzer](#rust_analyzer)
1616
* [rust_analyzer_aspect](#rust_analyzer_aspect)
17-
* [rust_benchmark](#rust_benchmark)
1817
* [rust_binary](#rust_binary)
1918
* [rust_bindgen](#rust_bindgen)
2019
* [rust_bindgen_library](#rust_bindgen_library)
@@ -216,116 +215,6 @@ Produces a rust-project.json for the given targets. Configure rust-analyzer to l
216215
| <a id="rust_analyzer-targets"></a>targets | List of all targets to be included in the index | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
217216

218217

219-
<a id="#rust_benchmark"></a>
220-
221-
## rust_benchmark
222-
223-
<pre>
224-
rust_benchmark(<a href="#rust_benchmark-name">name</a>, <a href="#rust_benchmark-aliases">aliases</a>, <a href="#rust_benchmark-compile_data">compile_data</a>, <a href="#rust_benchmark-crate_features">crate_features</a>, <a href="#rust_benchmark-crate_name">crate_name</a>, <a href="#rust_benchmark-crate_root">crate_root</a>, <a href="#rust_benchmark-data">data</a>,
225-
<a href="#rust_benchmark-default_args">default_args</a>, <a href="#rust_benchmark-deps">deps</a>, <a href="#rust_benchmark-edition">edition</a>, <a href="#rust_benchmark-proc_macro_deps">proc_macro_deps</a>, <a href="#rust_benchmark-rustc_env">rustc_env</a>, <a href="#rust_benchmark-rustc_env_files">rustc_env_files</a>, <a href="#rust_benchmark-rustc_flags">rustc_flags</a>,
226-
<a href="#rust_benchmark-srcs">srcs</a>, <a href="#rust_benchmark-use_libtest_harness">use_libtest_harness</a>, <a href="#rust_benchmark-version">version</a>)
227-
</pre>
228-
229-
Builds a Rust benchmark test.
230-
231-
**Warning**: This rule is currently experimental. [Rust Benchmark tests][rust-bench] require the `Bencher` interface in the unstable `libtest` crate, which is behind the `test` unstable feature gate. As a result, using this rule would require using a nightly binary release of Rust.
232-
233-
[rust-bench]: https://doc.rust-lang.org/nightly/unstable-book/library-features/test.html
234-
235-
Example:
236-
237-
Suppose you have the following directory structure for a Rust project with a library crate, `fibonacci` with benchmarks under the `benches/` directory:
238-
239-
```output
240-
[workspace]/
241-
WORKSPACE
242-
fibonacci/
243-
BUILD
244-
src/
245-
lib.rs
246-
benches/
247-
fibonacci_bench.rs
248-
```
249-
250-
`fibonacci/src/lib.rs`:
251-
```rust
252-
pub fn fibonacci(n: u64) -> u64 {
253-
if n < 2 {
254-
return n;
255-
}
256-
let mut n1: u64 = 0;
257-
let mut n2: u64 = 1;
258-
for _ in 1..n {
259-
let sum = n1 + n2;
260-
n1 = n2;
261-
n2 = sum;
262-
}
263-
n2
264-
}
265-
```
266-
267-
`fibonacci/benches/fibonacci_bench.rs`:
268-
```rust
269-
#![feature(test)]
270-
271-
extern crate test;
272-
extern crate fibonacci;
273-
274-
use test::Bencher;
275-
276-
#[bench]
277-
fn bench_fibonacci(b: &mut Bencher) {
278-
b.iter(|| fibonacci::fibonacci(40));
279-
}
280-
```
281-
282-
To build the benchmark test, add a `rust_benchmark` target:
283-
284-
`fibonacci/BUILD`:
285-
```python
286-
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_benchmark")
287-
288-
package(default_visibility = ["//visibility:public"])
289-
290-
rust_library(
291-
name = "fibonacci",
292-
srcs = ["src/lib.rs"],
293-
)
294-
295-
rust_benchmark(
296-
name = "fibonacci_bench",
297-
srcs = ["benches/fibonacci_bench.rs"],
298-
deps = [":fibonacci"],
299-
)
300-
```
301-
302-
Run the benchmark test using: `bazel run //fibonacci:fibonacci_bench`.
303-
304-
305-
**ATTRIBUTES**
306-
307-
308-
| Name | Description | Type | Mandatory | Default |
309-
| :------------- | :------------- | :------------- | :------------- | :------------- |
310-
| <a id="rust_benchmark-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
311-
| <a id="rust_benchmark-aliases"></a>aliases | Remap crates to a new name or moniker for linkage to this target<br><br>These are other <code>rust_library</code> targets and will be presented as the new name given. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: Label -> String</a> | optional | {} |
312-
| <a id="rust_benchmark-compile_data"></a>compile_data | List of files used by this rule at compile time.<br><br>This attribute can be used to specify any data files that are embedded into the library, such as via the [<code>include_str!</code>](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
313-
| <a id="rust_benchmark-crate_features"></a>crate_features | List of features to enable for this crate.<br><br>Features are defined in the code using the <code>#[cfg(feature = "foo")]</code> configuration option. The features listed here will be passed to <code>rustc</code> with <code>--cfg feature="${feature_name}"</code> flags. | List of strings | optional | [] |
314-
| <a id="rust_benchmark-crate_name"></a>crate_name | Crate name to use for this target.<br><br>This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores. | String | optional | "" |
315-
| <a id="rust_benchmark-crate_root"></a>crate_root | The file that will be passed to <code>rustc</code> to be used for building this crate.<br><br>If <code>crate_root</code> is not set, then this rule will look for a <code>lib.rs</code> file (or <code>main.rs</code> for rust_binary) or the single file in <code>srcs</code> if <code>srcs</code> contains only one file. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
316-
| <a id="rust_benchmark-data"></a>data | List of files used by this rule at compile time and runtime.<br><br>If including data at compile time with include_str!() and similar, prefer <code>compile_data</code> over <code>data</code>, to prevent the data also being included in the runfiles. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
317-
| <a id="rust_benchmark-default_args"></a>default_args | The default arguments to pass to the benchmark binary. This attribute is used if the built-in <code>args</code> attribute is not set. | List of strings | optional | ["--bench"] |
318-
| <a id="rust_benchmark-deps"></a>deps | List of other libraries to be linked to this library target.<br><br>These can be either other <code>rust_library</code> targets or <code>cc_library</code> targets if linking a native library. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
319-
| <a id="rust_benchmark-edition"></a>edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | "" |
320-
| <a id="rust_benchmark-proc_macro_deps"></a>proc_macro_deps | List of <code>rust_library</code> targets with kind <code>proc-macro</code> used to help build this library target. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
321-
| <a id="rust_benchmark-rustc_env"></a>rustc_env | Dictionary of additional <code>"key": "value"</code> environment variables to set for rustc.<br><br>rust_test()/rust_binary() rules can use $(rootpath //package:target) to pass in the location of a generated file or external tool. Cargo build scripts that wish to expand locations should use cargo_build_script()'s build_script_env argument instead, as build scripts are run in a different environment - see cargo_build_script()'s documentation for more. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
322-
| <a id="rust_benchmark-rustc_env_files"></a>rustc_env_files | Files containing additional environment variables to set for rustc.<br><br>These files should contain a single variable per line, of format <code>NAME=value</code>, and newlines may be included in a value by ending a line with a trailing back-slash (<code>\</code>).<br><br>The order that these files will be processed is unspecified, so multiple definitions of a particular variable are discouraged. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
323-
| <a id="rust_benchmark-rustc_flags"></a>rustc_flags | List of compiler flags passed to <code>rustc</code>.<br><br>These strings are subject to Make variable expansion for predefined source/output path variables like <code>$location</code>, <code>$execpath</code>, and <code>$rootpath</code>. This expansion is useful if you wish to pass a generated file of arguments to rustc: <code>@$(location //package:target)</code>. | List of strings | optional | [] |
324-
| <a id="rust_benchmark-srcs"></a>srcs | List of Rust <code>.rs</code> source files used to build the library.<br><br>If <code>srcs</code> contains more than one file, then there must be a file either named <code>lib.rs</code>. Otherwise, <code>crate_root</code> must be set to the source file that is the root of the crate to be passed to rustc to build this crate. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
325-
| <a id="rust_benchmark-use_libtest_harness"></a>use_libtest_harness | Generate the test harness for this benchmark. Note that [Criterion](https://bheisler.github.io/criterion.rs/book/index.html) benchmarks do not use a test harness, but the nightly <code>#[bench]</code> api does. Pass True if you have a <code>#[bench]</code> api test. | Boolean | optional | False |
326-
| <a id="rust_benchmark-version"></a>version | A version to inject in the cargo environment variable. | String | optional | "0.0.0" |
327-
328-
329218
<a id="#rust_binary"></a>
330219

331220
## rust_binary

docs/symbols.bzl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ load(
4646
_extra_rustc_flags = "extra_rustc_flags",
4747
_rust_analyzer = "rust_analyzer",
4848
_rust_analyzer_aspect = "rust_analyzer_aspect",
49-
_rust_benchmark = "rust_benchmark",
5049
_rust_binary = "rust_binary",
5150
_rust_clippy = "rust_clippy",
5251
_rust_clippy_aspect = "rust_clippy_aspect",
@@ -106,7 +105,6 @@ rust_test_suite = _rust_test_suite
106105
rust_doc = _rust_doc
107106
rust_doc_test = _rust_doc_test
108107

109-
rust_benchmark = _rust_benchmark
110108
rust_proto_library = _rust_proto_library
111109
rust_grpc_library = _rust_grpc_library
112110

0 commit comments

Comments
 (0)