aboutsummaryrefslogtreecommitdiff
path: root/crates/test_utils/src/bench_fixture.rs
blob: 41fcca635239b9d64f3eebc1c29b4fba2f559002 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
}