mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Infra for "unit" benchmarking
This commit is contained in:
parent
9ea2c96ddd
commit
4b1279d0b1
8 changed files with 102 additions and 4001 deletions
28
crates/test_utils/src/bench_fixture.rs
Normal file
28
crates/test_utils/src/bench_fixture.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
//! Generates large snippets of Rust code for usage in the benchmarks.
|
||||
|
||||
use stdx::format_to;
|
||||
|
||||
pub fn big_struct() -> String {
|
||||
let n = 1_000;
|
||||
|
||||
let mut buf = "pub struct RegisterBlock {".to_string();
|
||||
for i in 0..n {
|
||||
format_to!(buf, " /// Doc comment for {}.\n", i);
|
||||
format_to!(buf, " pub s{}: S{},\n", i, i);
|
||||
}
|
||||
buf.push_str("}\n\n");
|
||||
for i in 0..n {
|
||||
format_to!(
|
||||
buf,
|
||||
"
|
||||
|
||||
#[repr(transparent)]
|
||||
struct S{} {{
|
||||
field: u32,
|
||||
}}",
|
||||
i
|
||||
);
|
||||
}
|
||||
|
||||
buf
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue