aboutsummaryrefslogtreecommitdiff
path: root/crates/test_utils/src/bench_fixture.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/test_utils/src/bench_fixture.rs')
-rw-r--r--crates/test_utils/src/bench_fixture.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/test_utils/src/bench_fixture.rs b/crates/test_utils/src/bench_fixture.rs
new file mode 100644
index 000000000..41fcca635
--- /dev/null
+++ b/crates/test_utils/src/bench_fixture.rs
@@ -0,0 +1,28 @@
1//! Generates large snippets of Rust code for usage in the benchmarks.
2
3use stdx::format_to;
4
5pub fn big_struct() -> String {
6 let n = 1_000;
7
8 let mut buf = "pub struct RegisterBlock {".to_string();
9 for i in 0..n {
10 format_to!(buf, " /// Doc comment for {}.\n", i);
11 format_to!(buf, " pub s{}: S{},\n", i, i);
12 }
13 buf.push_str("}\n\n");
14 for i in 0..n {
15 format_to!(
16 buf,
17 "
18
19#[repr(transparent)]
20struct S{} {{
21 field: u32,
22}}",
23 i
24 );
25 }
26
27 buf
28}