test_utils/
bench_fixture.rs1use std::fs;
4
5use stdx::format_to;
6
7use crate::project_root;
8
9pub fn big_struct() -> String {
10 let n = 1_000;
11 big_struct_n(n)
12}
13
14pub fn big_struct_n(n: u32) -> String {
15 let mut buf = "pub struct RegisterBlock {".to_owned();
16 for i in 0..n {
17 format_to!(buf, " /// Doc comment for {}.\n", i);
18 format_to!(buf, " pub s{}: S{},\n", i, i);
19 }
20 buf.push_str("}\n\n");
21 for i in 0..n {
22 format_to!(
23 buf,
24 "
25
26#[repr(transparent)]
27struct S{} {{
28 field: u32,
29}}",
30 i
31 );
32 }
33
34 buf
35}
36
37pub fn glorious_old_parser() -> String {
38 let path = project_root().join("bench_data/glorious_old_parser");
39 fs::read_to_string(path).unwrap()
40}
41
42pub fn numerous_macro_rules() -> String {
43 let path = project_root().join("bench_data/numerous_macro_rules");
44 fs::read_to_string(path).unwrap()
45}